Skip to content

Commit 77495be

Browse files
authored
Update introduction.md
1 parent e14dd00 commit 77495be

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
@@ -64,6 +64,25 @@ The `SwaggerModule` automatically reflects all of your endpoints. Note that the
6464

6565
> 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`).
6666
67+
> 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:
68+
```ts
69+
app.register(helmet, {
70+
contentSecurityPolicy: {
71+
directives: {
72+
defaultSrc: [`'self'`],
73+
styleSrc: [`'self'`, `'unsafe-inline'`],
74+
imgSrc: [`'self'`, 'data:', 'validator.swagger.io'],
75+
scriptSrc: [`'self'`, `https: 'unsafe-inline'`],
76+
},
77+
},
78+
})
79+
80+
// If you are not going to use CSP at all, you can use this:
81+
app.register(helmet, {
82+
contentSecurityPolicy: false,
83+
})
84+
```
85+
6786
#### Example
6887

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

0 commit comments

Comments
 (0)