Skip to content

Commit

Permalink
fix: change cors
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-oberaj committed May 5, 2024
1 parent 1dde5f2 commit 9945b6f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions StudioManager.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddCors(option =>
{
option.AddPolicy("CorsPolicy", policy =>
{
policy.AllowAnyHeader()
.AllowAnyMethod()
.SetIsOriginAllowed(_ => true)
.AllowCredentials();
});
});

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
Expand All @@ -22,29 +32,18 @@
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
builder.Services.AddProblemDetails();

builder.Services.AddCors(opt =>
{
opt.AddDefaultPolicy(
policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});

var app = builder.Build();

app.UseExceptionHandler();
app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseCors();
app.UseCors("CorsPolicy");

app.UseAuthorization();
app.UseAuthentication();

app.UseStaticFiles();
app.UseExceptionHandler();

// Configure the HTTP request pipeline.
app.UseSwagger();
Expand Down

0 comments on commit 9945b6f

Please sign in to comment.