Skip to content

Commit 3171807

Browse files
Merge pull request #1662 from gitbugr/2021/docs/nest-6180-fastify-and-apollo-and-helmet-warnings
docs(fastify,helmet,apollo): add warnings
2 parents fdcf2d9 + 971d1d2 commit 3171807

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

content/security/helmet.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,23 @@ import * as helmet from 'fastify-helmet';
3737
// somewhere in your initialization file
3838
app.register(helmet);
3939
```
40+
> warning **Warning** When using `apollo-server-fastify` and `fastify-helmet`, there may be a problem with [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) on the GraphQL playground, to solve this collision, configure the CSP as shown below:
41+
>
42+
> ```typescript
43+
> app.register(helmet, {
44+
> contentSecurityPolicy: {
45+
> directives: {
46+
> defaultSrc: [`'self'`],
47+
> styleSrc: [`'self'`, `'unsafe-inline'`, 'cdn.jsdelivr.net', 'fonts.googleapis.com'],
48+
> fontSrc: [`'self'`, 'fonts.gstatic.com'],
49+
> imgSrc: [`'self'`, 'data:', 'cdn.jsdelivr.net'],
50+
> scriptSrc: [`'self'`, `https: 'unsafe-inline'`, `cdn.jsdelivr.net`],
51+
> },
52+
> },
53+
> });
54+
>
55+
> // If you are not going to use CSP at all, you can use this:
56+
> app.register(helmet, {
57+
> contentSecurityPolicy: false,
58+
> });
59+
> ```

content/techniques/performance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ First, we need to install the required package:
1515
```bash
1616
$ npm i --save @nestjs/platform-fastify
1717
```
18+
> warning **Warning** When using `@nestjs/platform-fastify` version `>=7.5.0` and `apollo-server-fastify`, GraphQL playground may not work due to incompatibility with `fastify` version `^3.0.0`. You may want to use the unstable `apollo-server-fastify` version `^3.0.0-alpha.3` or temporarily choose express instead.
1819
1920
#### Adapter
2021

0 commit comments

Comments
 (0)