Skip to content

Commit d7adb49

Browse files
authored
fix(helmet.md): correct config for csp
The suggested configs for CSP didn't work for me. However, after some adjustments, what I'm suggesting as change worked for me.
1 parent 90d1519 commit d7adb49

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

content/security/helmet.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,27 @@ await app.register(helmet)
4242
>
4343
> ```typescript
4444
> await app.register(fastifyHelmet, {
45-
> contentSecurityPolicy: {
46-
> directives: {
47-
> defaultSrc: [`'self'`],
48-
> styleSrc: [
49-
> `'self'`,
50-
> `'unsafe-inline'`,
51-
> 'cdn.jsdelivr.net',
52-
> 'fonts.googleapis.com',
53-
> ],
54-
> fontSrc: [`'self'`, 'fonts.gstatic.com'],
55-
> imgSrc: [`'self'`, 'data:', 'cdn.jsdelivr.net'],
56-
> scriptSrc: [`'self'`, `https: 'unsafe-inline'`, `cdn.jsdelivr.net`],
57-
> },
58-
> },
59-
> });
45+
> contentSecurityPolicy: {
46+
> directives: {
47+
> defaultSrc: [`'self'`, 'unpkg.com'],
48+
> styleSrc: [
49+
> `'self'`,
50+
> `'unsafe-inline'`,
51+
> 'cdn.jsdelivr.net',
52+
> 'fonts.googleapis.com',
53+
> 'unpkg.com',
54+
> ],
55+
> fontSrc: [`'self'`, 'fonts.gstatic.com', 'data:'],
56+
> imgSrc: [`'self'`, 'data:', 'cdn.jsdelivr.net'],
57+
> scriptSrc: [
58+
> `'self'`,
59+
> `https: 'unsafe-inline'`,
60+
> `cdn.jsdelivr.net`,
61+
> `'unsafe-eval'`,
62+
> ],
63+
> },
64+
> },
65+
> });
6066
>
6167
> // If you are not going to use CSP at all, you can use this:
6268
> await app.register(fastifyHelmet, {

0 commit comments

Comments
 (0)