Skip to content

Commit

Permalink
[AC-1971] Add SwaggerUI to CORS policy (bitwarden#3583)
Browse files Browse the repository at this point in the history
* Allow SwaggerUI authorize requests if in development
  • Loading branch information
eliykat authored Dec 19, 2023
1 parent c2d36cb commit af7811b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Identity/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ public void Configure(
app.UseRouting();

// Add Cors
app.UseCors(policy => policy.SetIsOriginAllowed(o => CoreHelpers.IsCorsOriginAllowed(o, globalSettings))
app.UseCors(policy => policy.SetIsOriginAllowed(o =>
CoreHelpers.IsCorsOriginAllowed(o, globalSettings) ||

// If development - allow requests from the Swagger UI so it can authorize
(Environment.IsDevelopment() && o == globalSettings.BaseServiceUri.Api))
.AllowAnyMethod().AllowAnyHeader().AllowCredentials());

// Add current context
Expand Down

0 comments on commit af7811b

Please sign in to comment.