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

How I can see the swagger-html UI ? #106

Open
kevinblade opened this issue Feb 22, 2021 · 2 comments
Open

How I can see the swagger-html UI ? #106

kevinblade opened this issue Feb 22, 2021 · 2 comments

Comments

@kevinblade
Copy link

Hi!
I can't see the swagger-html UI but swagger-json.
What is the problem?
Chrome DevTools console log as follows

Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.21.0/swagger-ui-bundle.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

swagger-html:1 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.21.0/swagger-ui-standalone-preset.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

swagger-html:70 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-aprqhcGIuEdFHjJ3tLbisxpYmlmPTnIKzn9fwWb7iGg='), or a nonce ('nonce-...') is required to enable inline execution.

@kevinblade kevinblade changed the title Can't see the swagger-html UI How I can see the swagger-html UI ? Feb 22, 2021
@thomasmost
Copy link

are you running locally or in a hosted environment?

@johnny5th
Copy link

Here's what I did to allow showing the swagger-html page while in development mode:
Disable CSP when NODE_ENV is in development
server.ts

app.use(helmet({
  contentSecurityPolicy: process.env.NODE_ENV === 'development' ? false : true,
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants