Skip to content

Commit 3ee09b7

Browse files
Merge branch 'H6LS1S-patch-1'
2 parents 618545a + a8bc20a commit 3ee09b7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

content/openapi/introduction.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ 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 shown below:
70+
>
71+
> ```typescript
72+
> app.register(helmet, {
73+
> contentSecurityPolicy: {
74+
> directives: {
75+
> defaultSrc: [`'self'`],
76+
> styleSrc: [`'self'`, `'unsafe-inline'`],
77+
> imgSrc: [`'self'`, 'data:', 'validator.swagger.io'],
78+
> scriptSrc: [`'self'`, `https: 'unsafe-inline'`],
79+
> },
80+
> },
81+
> });
82+
>
83+
> // If you are not going to use CSP at all, you can use this:
84+
> app.register(helmet, {
85+
> contentSecurityPolicy: false,
86+
> });
87+
> ```
88+
6989
#### Example
7090
7191
A working example is available [here](https://github.com/nestjs/nest/tree/master/sample/11-swagger).

0 commit comments

Comments
 (0)