Skip to content

Commit 48d5b9d

Browse files
Merge branch 'patch-1' of https://github.com/H6LS1S/docs.nestjs.com into H6LS1S-patch-1
2 parents 618545a + 77495be commit 48d5b9d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

content/openapi/introduction.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ The `SwaggerModule` automatically reflects all of your endpoints. Note that the
6666

6767
> info **Hint** To generate and download a Swagger JSON file, navigate to `http://localhost:3000/api-json` (`swagger-ui-express`) or `http://localhost:3000/api/json` (`fastify-swagger`) in your browser (assuming that your Swagger documentation is available under `http://localhost:3000/api`).
6868
69+
> warning **Warning** When using `fastify-swagger` and `helmet`, there may be a problem with [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), to solve this collision, configure the CSP as indicated below:
70+
```ts
71+
app.register(helmet, {
72+
contentSecurityPolicy: {
73+
directives: {
74+
defaultSrc: [`'self'`],
75+
styleSrc: [`'self'`, `'unsafe-inline'`],
76+
imgSrc: [`'self'`, 'data:', 'validator.swagger.io'],
77+
scriptSrc: [`'self'`, `https: 'unsafe-inline'`],
78+
},
79+
},
80+
})
81+
82+
// If you are not going to use CSP at all, you can use this:
83+
app.register(helmet, {
84+
contentSecurityPolicy: false,
85+
})
86+
```
87+
6988
#### Example
7089

7190
A working example is available [here](https://github.com/nestjs/nest/tree/master/sample/11-swagger).

0 commit comments

Comments
 (0)