Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Created September 1, 2023 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj-nitehawk/bb78ba5dc07c1e20538c046ad7e154c2 to your computer and use it in GitHub Desktop.
Save dj-nitehawk/bb78ba5dc07c1e20538c046ad7e154c2 to your computer and use it in GitHub Desktop.
Correct middleware order for UseSpa() from Microsoft.AspNetCore.SpaServices.Extensions
var builder = WebApplication.CreateBuilder();
builder.Services.AddFastEndpoints();
var app = builder.Build();
app.UseRouting(); //should be before auth/cors/fastendpoints middlewares.
app.UseAuthorization();
app.UseFastEndpoints();
app.UseEndpoints(_ => { }); //should be right after UseFastEndpoints(). this is the terminating middleware for endpoint routes.
if (app.Environment.IsDevelopment())
app.UseSpa(x => x.UseProxyToSpaDevelopmentServer("http://localhost:8001"));
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment