Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
n0n3br opened this issue Aug 16, 2020 · 6 comments
Closed

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

n0n3br opened this issue Aug 16, 2020 · 6 comments

Comments

@n0n3br
Copy link

n0n3br commented Aug 16, 2020

I've configured a no ssl server on my machine and swagger works fine.

When I deploy the application to the productions server (debian 9), everytime I try to access the documentation route it tries to fetch resoursce files (swagger-ui.css for example) via https. Since there's no https server configured, it never loads the page.

Is there someway to force using only http ?

@n0n3br n0n3br closed this as completed Aug 16, 2020
@nartc
Copy link

nartc commented Oct 23, 2020

@n0n3br How did you resolve this?

@n0n3br
Copy link
Author

n0n3br commented Oct 23, 2020

Unfortunately no.

@taipoxin
Copy link

@n0n3br
In my case I just needed to remove helmet express extension from my setup and everything goes normally. I think for swagger it should be configured manually or be removed.

@thomasgauvin
Copy link

Removing helmet did not work for me

@meSmashsta
Copy link

Guys no need to remove helmet, just move the swagger above the helmet registration like so:

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

app.use(helmet());

@nxncode
Copy link

nxncode commented Aug 12, 2022

Try using Swagger version 4.1.3. It solved my problem.
npm i swagger-ui-express@4.1.3

dbwogus94 added a commit to dbwogus94/boilerplate-nestjs that referenced this issue Feb 20, 2024
[관련 git issues](scottie1984/swagger-ui-express#212 (comment))

- helmet 이 swagger ui보다 먼저 적용되는 경우 발생하는 에러로 적용 순서를 변경하여 해결하였다
dbwogus94 added a commit to dbwogus94/boilerplate-nestjs that referenced this issue Feb 20, 2024
[관련 git issues](scottie1984/swagger-ui-express#212 (comment))

- helmet 이 swagger ui보다 먼저 적용되는 경우 발생하는 에러로 적용 순서를 변경하여 해결하였다
dbwogus94 added a commit to dbwogus94/boilerplate-nestjs that referenced this issue Feb 20, 2024
[관련 git issues](scottie1984/swagger-ui-express#212 (comment))

- helmet 이 swagger ui보다 먼저 적용되는 경우 발생하는 에러로 적용 순서를 변경하여 해결하였다

(cherry picked from commit cc1b31a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants