Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k
stars
226
forks
source link
Swagger-UI not loading in Azure App Service: 404 Not Found #254
I am able to pull up the Swagger-UI api-docs path locally without issue, but in attempting to load within a Node.js app hosted in an Azure App Service, it gives me a 404 not found when trying to hit the /api-docs/ endpoint. The rest of my node app loads in the Node Azure App Service. Of note, the 404 states the requested URL is: https://myapp:80/api-docs/
I have both URLs for my local instance and the Azure instance listed in the swaggerOptions/swaggerDefinition:
const swaggerOptions = {
swaggerDefinition: {
info: {
version: "1.0.0",
title: "My API",
description: "My API Information",
contact: {
name: "My Name - my.name@email.com"
},
urls: [{"url":"http://localhost:3000", "description": "Development server"},{"url":"https://myapp.azurewebsites.net", "description": "Production server"}]
}
},
// ['.routes/*.js']
apis: ["server.js"]
};
const swaggerDocs = swaggerJsDoc(swaggerOptions);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
We can close this issue. My package.json did not have the correct file listed (it had index.js where I use server.js). Correcting this with a fresh deployment allowed Azure to read properly.
Hello all,
I am able to pull up the Swagger-UI api-docs path locally without issue, but in attempting to load within a Node.js app hosted in an Azure App Service, it gives me a 404 not found when trying to hit the /api-docs/ endpoint. The rest of my node app loads in the Node Azure App Service. Of note, the 404 states the requested URL is: https://myapp:80/api-docs/
I have both URLs for my local instance and the Azure instance listed in the swaggerOptions/swaggerDefinition: