Reputation: 2223
I'm upgrading a Web API project from AspNetCore 2.1 to 3.1 and unfortunately, post-upgrade our SwaggerUI page returns an HTTP 401 error when attempting to access it. How do I exclude a specific endpoint in AspNetCore 3.1 from requiring authentication and authorization to access it? I've been scouring the internet for the past few hours and haven't found anything pertaining to AspNetCore 3.1.
Upvotes: 1
Views: 2731
Reputation: 2223
Okay so this fix is specific to Swagger only; I'm not sure how to implement this for other endpoints, but apparently if you move the Swagger code above the calls to services.AddAuthentication() and services.AddAuthorization() in your web services' Startup.cs files, this will allow the Swagger pages to be available without the user having to go through authentication and authorization.
Upvotes: 3