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: docs/4.x/config/app.md
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -509,3 +509,63 @@ return [
509
509
'bootstrap' => ['my-module'],
510
510
];
511
511
```
512
+
513
+
## Requests + Responses <Sincever="4.11.0"feature="CORS and headers filters" />
514
+
515
+
To set arbitrary headers on every site response, attach <craft4:craft\filters\Headers> to the root _web_ application, in `config/app.web.php`:
516
+
517
+
```php
518
+
return [
519
+
// Attach the headers filter to the application:
520
+
'as headersFilter' => [
521
+
'class' => \craft\filters\Headers::class,
522
+
'site' => ['siteA', 'siteB'],
523
+
'headers' => [
524
+
// Define pairs of headers:
525
+
'Permissions-Policy' => 'interest-cohort=()',
526
+
'X-Foo' => 'Bar',
527
+
],
528
+
],
529
+
];
530
+
```
531
+
532
+
We also provide a [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)-specific filter (<craft4:craft\filters\Cors>) to manage server-side policies on a per-action basis:
Copy file name to clipboardExpand all lines: docs/5.x/reference/config/app.md
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -513,3 +513,63 @@ return [
513
513
'bootstrap' => ['my-module'],
514
514
];
515
515
```
516
+
517
+
## Requests + Responses <Sincever="5.3.0"feature="CORS and headers filters" />
518
+
519
+
To set arbitrary headers on every site response, attach <craft5:craft\filters\Headers> to the root _web_ application, in `config/app.web.php`:
520
+
521
+
```php
522
+
return [
523
+
// Attach the headers filter to the application:
524
+
'as headersFilter' => [
525
+
'class' => \craft\filters\Headers::class,
526
+
'site' => ['siteA', 'siteB'],
527
+
'headers' => [
528
+
// Define pairs of headers:
529
+
'Permissions-Policy' => 'interest-cohort=()',
530
+
'X-Foo' => 'Bar',
531
+
],
532
+
],
533
+
];
534
+
```
535
+
536
+
We also provide a [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)-specific filter (<craft5:craft\filters\Cors>) to manage server-side policies on a per-action basis:
0 commit comments