Skip to content

Commit

Permalink
added cors
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil1010 committed Jun 4, 2021
1 parent 250d719 commit 3d10e61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FewaTelemedicine/Controllers/PracticeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using FewaTelemedicine.Domain.Services;
using FewaTelemedicine.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -44,6 +45,7 @@

namespace FewaTelemedicine.Controllers
{
[EnableCors("MyPolicy")]
[Authorize]
public class PracticeController : Controller
{
Expand Down
7 changes: 7 additions & 0 deletions FewaTelemedicine/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public void ConfigureServices(IServiceCollection services)
options.KeepAliveInterval = TimeSpan.FromSeconds(30);
options.ClientTimeoutInterval = TimeSpan.FromMinutes(120);
}));
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
services.AddControllersWithViews();

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
Expand Down Expand Up @@ -140,6 +146,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseStaticFiles();

app.UseRouting();
app.UseCors("MyPolicy");
app.UseAuthentication();
app.UseAuthorization();

Expand Down

0 comments on commit 3d10e61

Please sign in to comment.