2

I have developed Node.js App using Express framework and documented using "swagger-jsdoc" and "swagger-ui-express". Swagger UI is loading on my "localhost:3000/v1/docs" and working properly.

Now, I deployed it to Amazon EC2 instance (Ubuntu, Linux), all API's are hitting and working properly but "myamazonurl.com/v1/docs" are redirecting to Swagger UI but not displaying anything.

I configured pm2 and nginx as well.

Errors coming in console and network are same and they are attached.

On first hit to the URL:

On first hit to the URL

On reloading the page:

On reloading the page

Is there any additional configuration or setup is required to run Swagger UI? What is the issue?

I'll be thankful...

Akber Iqbal
  • 14,487
  • 12
  • 48
  • 70

1 Answers1

1

just move the swagger configuration above the app.use(helmet()); plugin :-

const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('../swagger.json');
app.use('/v1/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(helmet());

it is forcing to find resources on https scheme, even if it's not configured yet.

Source: Github

Lakshman Kambam
  • 1,498
  • 13
  • 20