Hello, I've just installed koa2-swagger-ui package via npm and I've updated my code with the settings on the documentation, however, for some reason, it does not load the swagger.json file.
The /docs route opens a blank page. When I inspect the console log, it shows some error messages:
Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.1.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.
docs:1 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.1.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.
docs:71 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-CUXEv2EIcoCxm5IYzJhXO4B2nBMWti4GA5+EGW7dpG4='), or a nonce ('nonce-...') is required to enable inline execution.
I've tried to add the package to my project on both ways the documentation describes, directly to koa app and through koa-router, but both options show the same messages above.
I send below a sample of my code:
import Koa from 'koa';
import { koaSwagger } from 'koa2-swagger-ui';
import Router from 'koa-router';
let app = new Koa();
let router = new Router();
app.use(koaSwagger({
routePrefix: '/docs',
swaggerOptions: {
url: 'http://petstore.swagger.io/v2/swagger.json',
}
}));
// or
router.use(koaSwagger({
routePrefix: '/docs',
swaggerOptions: {
url: 'http://petstore.swagger.io/v2/swagger.json',
}
}));
Hello, I've just installed koa2-swagger-ui package via npm and I've updated my code with the settings on the documentation, however, for some reason, it does not load the swagger.json file.
The
/docs
route opens a blank page. When I inspect the console log, it shows some error messages:I've tried to add the package to my project on both ways the documentation describes, directly to koa app and through koa-router, but both options show the same messages above.
I send below a sample of my code:
My dependencies are:
Thank you in advance.