scottie1984 / swagger-ui-express

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 228 forks source link

Swagger trying to get content via https on non ssl express server #346

Open runlong-yao opened 1 year ago

runlong-yao commented 1 year ago

It looks like #212 I face the problem with swagger-ui-express@4.6.3

I try: 1、remove helmet, but not working. 2、use swagger-ui-express@4.1.3 , working.

bebrasmell commented 8 months ago

Okay, It might be an issue with Content-Security-Policy. This worked for me:

api.use(
      '/swagger',
      (req: Request, res: Response, next: NextFunction) => {
        res.setHeader('Content-Security-Policy', `script-src 'self'`);
        next();
      },
      swagger.serve,
      swagger.setup(docs, opts),
    );