Skip to content

Commit 9861e61

Browse files
committed
fix: permissions policy
1 parent 5d9740a commit 9861e61

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

docs/content/1.documentation/1.getting-started/2.configuration.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ security: {
6666
xPermittedCrossDomainPolicies: 'none',
6767
xXSSProtection: '0',
6868
permissionsPolicy: {
69-
camera: ['()'],
70-
'display-capture': ['()'],
71-
fullscreen: ['()'],
72-
geolocation: ['()'],
73-
microphone: ['()']
69+
camera: [],
70+
'display-capture': [],
71+
fullscreen: [],
72+
geolocation: [],
73+
microphone: []
7474
}
7575
},
7676
requestSizeLimiter: {

docs/content/1.documentation/1.getting-started/3.usage.md

-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ experimental: {
9696

9797
::
9898

99-
100-
101-
10299
## Disabling functionality
103100

104101
To disable certain middleware or headers, follow this pattern:

docs/content/1.documentation/2.headers/2.permissions-policy.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ export default defineNuxtConfig({
3636
})
3737
```
3838

39-
You can also disable this header by `permissionsPolicy: false`.
39+
You can also disable this header by setting `permissionsPolicy: false`. To disable certain API completely, set its value to empty array like:
40+
41+
```ts
42+
export default defineNuxtConfig({
43+
security: {
44+
headers: {
45+
permissionsPolicy: {
46+
'camera': [] // This will block usage of camera by this website
47+
},
48+
},
49+
},
50+
})
51+
```
4052

4153
## Default value
4254

src/defaultConfig.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export const defaultSecurityConfig = (serverlUrl: string): ModuleOptions => ({
3131
xPermittedCrossDomainPolicies: 'none',
3232
xXSSProtection: '0',
3333
permissionsPolicy: {
34-
camera: ['()'],
35-
'display-capture': ['()'],
36-
fullscreen: ['()'],
37-
geolocation: ['()'],
38-
microphone: ['()']
34+
camera: [],
35+
'display-capture': [],
36+
fullscreen: [],
37+
geolocation: [],
38+
microphone: []
3939
}
4040
},
4141
requestSizeLimiter: {

src/headers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const headerValueMappers = {
4141
})
4242
.filter(Boolean).join('; ')
4343
},
44-
permissionsPolicy: (value: PermissionsPolicyValue) => Object.entries(value).map(([directive, sources]) => (sources as string[])?.length && `${directive}=${(sources as string[]).join(' ')}`).filter(Boolean).join(', ')
44+
permissionsPolicy: (value: PermissionsPolicyValue) => Object.entries(value).map(([directive, sources]) => `${directive}=(${(sources as string[]).join(' ')})`).filter(Boolean).join(', ')
4545
}
4646

4747
export const getHeaderValueFromOptions = <T>(headerType: HeaderMapper, headerOptions: any) => {

0 commit comments

Comments
 (0)