Description
The problem
I was reading the docs on upgrading a 2.1 app to 3.1 which used endpoint routing and could not figure out why my routes were not being picked up. It turned out that app.UseEndpoints(...)
needed to be placed before app.UseSpa(...)
.
There were many warnings in the migration docs about the configuration order eg:
If the app calls
UseStaticFiles
, placeUseStaticFiles
beforeUseRouting
.
For most apps, calls to
UseAuthentication
,UseAuthorization
, andUseCors
must appear between the calls toUseRouting
andUseEndpoints
to be effective.
There were no warnings about endpoints and spa. I had to generate a new SPA template to look at the order to finally figure out what the issue was.
Describe the solution you'd like
It would be great if the order of app.UseX
was not so critical to a functioning application. All of the gotchas and warnings would be unnecessary. I know there are technical reasons for pipeline registration but I would think that something could sit in the middle and build the configuration in the proper order.
Since I'm sure you've already discussed this and decided to push this onto the developers, I think some documentation around the endpoints and spa needs to be specifically added. Maybe some sort of ordered master list info graphic of when to register what could help.
I was getting tripped up because the spa static files were being returned instead of the api route even though my use endpoints and use routing configuration were after the use static files and use spa static files.