Skip to content

Commit

Permalink
Merge pull request #44 from wemogy:fix/cors-order
Browse files Browse the repository at this point in the history
Fix order of adding CORS
  • Loading branch information
robinmanuelthiel authored Oct 20, 2023
2 parents 9cac29f + 85db5b9 commit e7437cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Wemogy.AspNet/Startup/StartupExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public static void UseDefaultSetup(this IApplicationBuilder applicationBuilder,
applicationBuilder.UseDeveloperExceptionPage();
}

// Must come before any "UseSwagger()" calls because the Swagger middleware, when it knows that the request
// is for Swagger, it doesn't forward the request onto the next middleware, it just immediately returns.
applicationBuilder.UseDefaultCors();

if (options.OpenApiEnvironment != null)
{
applicationBuilder.UseDefaultSwagger(options.OpenApiEnvironment);
Expand All @@ -103,8 +107,6 @@ public static void UseDefaultSetup(this IApplicationBuilder applicationBuilder,
applicationBuilder.UseCloudEvents();
}

applicationBuilder.UseDefaultCors();

applicationBuilder.UseAuthentication();
applicationBuilder.UseAuthorization();

Expand Down

0 comments on commit e7437cc

Please sign in to comment.