You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/security/helmet.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Once the installation is complete, apply it as a global middleware.
17
17
```typescript
18
18
import*ashelmetfrom'helmet';
19
19
// somewhere in your initialization file
20
-
app.use(helmet());
20
+
awaitapp.use(helmet());
21
21
```
22
22
23
23
> info **Hint** If you are getting the `This expression is not callable` error while trying to import `Helmet`, you very likely have the `allowSyntheticDefaultImports` and `esModuleInterop` options set to `true` in your project's `tsconfig.json` file. If that's the case, change the import statement to: `import helmet from 'helmet'` instead.
@@ -35,12 +35,12 @@ $ npm i --save fastify-helmet
35
35
```typescript
36
36
import { fastifyHelmet } from'fastify-helmet';
37
37
// somewhere in your initialization file
38
-
app.register(helmet);
38
+
awaitapp.register(helmet);
39
39
```
40
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
41
>
42
42
> ```typescript
43
-
>app.register(helmet, {
43
+
>awaitapp.register(helmet, {
44
44
> contentSecurityPolicy: {
45
45
> directives: {
46
46
> defaultSrc: [`'self'`],
@@ -53,7 +53,7 @@ app.register(helmet);
53
53
> });
54
54
>
55
55
>// If you are not going to use CSP at all, you can use this:
0 commit comments