ASP.NET Core Web API project is configured with Swagger. When I run the project on my local machine the launchUrl works correctly and automatically redirects to my Swagger apidocs location (https://localhost:44373/apidocs/index.html)
But as soon as I publish the project on Azure the launchUrl no longer works correctly. (https://myapiurl.com) => Should'nd this redirect automatically to (https://myapiurl.com/apidocs/index.html) ?
What am I missing for the published environment?
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60837",
"sslPort": 44373
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "apidocs",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"Web.Apis.Organization": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "apidocs",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
My COnfigure Method
app.UseStaticFiles();
// Enable middle-ware to serve generated Swagger as a JSON endpoint. https://github.com/domaindrivendev/Swashbuckle.AspNetCore#generate-multiple-swagger-documents
app.UseSwagger(options =>
{
options.RouteTemplate = "apidocs/{documentName}/apispec.json";
});
//Enable middle-ware to serve swagger - ui(HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
// https://dejanstojanovic.net/aspnet/2018/november/setting-up-swagger-to-support-versioned-api-endpoints-in-aspnet-core/
// https://github.com/microsoft/aspnet-api-versioning/issues/516
app.UseSwaggerUI(c =>
{
c.RoutePrefix = "apidocs";
//Build a swagger endpoint for each discovered API version
foreach (var apiDescription in apiVersionProvider.ApiVersionDescriptions)
{
c.SwaggerEndpoint($"/{c.RoutePrefix}/{apiDescription.GroupName}/apispec.json", $"Version { apiDescription.ApiVersion.ToString()}");
}
c.DisplayRequestDuration();
c.DocumentTitle = GlobalConstants.OrganizationFullName;
// Custom Index
c.IndexStream = () => GetType().Assembly.GetManifestResourceStream("Web.Apis.Organization.wwwroot.swagger_ui.index.html");
// Custom style
//c.InjectStylesheet("/swagger-ui/custom.css");
//c.InjectJavascript("/swagger-ui/custom.js");
});