Skip to content

Commit

Permalink
feat: improve cors settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Jul 15, 2021
1 parent 11775b4 commit 6fe6b6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Armory.Api/Extensions/Infrastructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public static IApplicationBuilder UseSwaggerDocumentation(this IApplicationBuild
public static IApplicationBuilder ConfigureCors(this IApplicationBuilder app, IConfiguration configuration)
{
var allowedUrls = configuration.GetSection("AllowedUrls").Get<List<string>>();
app.UseCors(c => c.WithOrigins(allowedUrls.ToArray()).AllowAnyHeader().AllowAnyMethod());
app.UseCors(c =>
c.WithOrigins(allowedUrls.ToArray()).AllowAnyHeader().AllowAnyMethod().AllowCredentials());

return app;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Armory.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RoleManager<ArmoryRole> roleManager)
{
app.ConfigureCors(Configuration);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwaggerDocumentation();
}

app.UseHttpsRedirection();
app.ConfigureCors(Configuration);

app.UseRouting();

Expand Down

0 comments on commit 6fe6b6c

Please sign in to comment.