When loading the /swagger/index.html page the browser can't find the swagger-ui resources required when deployed to an App Servicce in Azure, returning 404. It works when running locally. My setup is:
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Nexus WebApp",
Version = "v1"
});
options.CustomSchemaIds(type => type.ToString());
});
var builder = endpoints.CreateApplicationBuilder();
builder.UseSwagger();
builder.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Nexus WebApp");
});
var pipeline = builder.Build();
endpoints.Map("/swagger", pipeline)
.RequireAuthorization(new AuthorizeAttribute());
endpoints.Map("/swagger/index.html", pipeline)
.RequireAuthorization(new AuthorizeAttribute());
endpoints.Map("/swagger/{documentName}/swagger.json", pipeline)
.RequireAuthorization(new AuthorizeAttribute());
I've tried with a relative path fro the swagger endpoint like so ..\swagger\v1/swagger.json, I've tried specifying a RoutePrefix all to no avail unfortunately. I'm aware similar questions have been asked but unfortunately none seem to help.
Does anyone have any clues?
Update
These are the resources it is returning 404 for:
- https://{domain}/swagger/swagger-ui.css
- https://{domain}/swagger/swagger-ui-standalone-preset.js
- https://{domain}/swagger/swagger-ui-bundle.js