diff --git a/src/Wemogy.AspNet/Startup/StartupExtensions.cs b/src/Wemogy.AspNet/Startup/StartupExtensions.cs index 57c5bf2..51ce0ee 100644 --- a/src/Wemogy.AspNet/Startup/StartupExtensions.cs +++ b/src/Wemogy.AspNet/Startup/StartupExtensions.cs @@ -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); @@ -103,8 +107,6 @@ public static void UseDefaultSetup(this IApplicationBuilder applicationBuilder, applicationBuilder.UseCloudEvents(); } - applicationBuilder.UseDefaultCors(); - applicationBuilder.UseAuthentication(); applicationBuilder.UseAuthorization();