Skip to content

Commit

Permalink
Merge pull request #5 from kamil-oberaj/KO/equipment
Browse files Browse the repository at this point in the history
fix: CORS
  • Loading branch information
kamil-oberaj authored May 5, 2024
2 parents f594c90 + 4a23db5 commit 1dcb07d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions StudioManager.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

var builder = WebApplication.CreateBuilder(args);

const string policyName = "DefaultPolicy";
builder.Services.AddCors(opt =>
{
opt.AddDefaultPolicy(pol =>
opt.AddPolicy(name: policyName, pol =>
{
pol.WithOrigins("*");
pol.AllowAnyHeader();
pol.AllowAnyMethod();
pol.AllowAnyOrigin();
pol.WithOrigins("http://127.0.0.1:4200")
.SetIsOriginAllowedToAllowWildcardSubdomains();
pol.WithOrigins("http://127.0.0.1:3000")
.SetIsOriginAllowedToAllowWildcardSubdomains();
});
});

Expand All @@ -38,12 +39,7 @@
app.UseStaticFiles();
app.UseRouting();

app.UseCors(opt =>
{
opt.AllowAnyOrigin();
opt.AllowAnyMethod();
opt.AllowAnyHeader();
});
app.UseCors(policyName);

app.UseExceptionHandler();

Expand Down

0 comments on commit 1dcb07d

Please sign in to comment.