Skip to content

Commit 31a1724

Browse files
authored
Merge pull request #739 from craftcms/feature/cloud-rewrite-headers
Custom headers in Cloud rewrite rules
2 parents 52dd5ca + ea34498 commit 31a1724

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/cloud/redirects.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,18 @@ rewrites:
126126
pathname: '/(favicon.ico|.well-known|dist)/*?'
127127
destination: '{artifactBaseUrl}/{request.uri}'
128128
```
129+
130+
### Custom Headers <Since ver="2.16.0" repo="craftcms/cloud-extension-yii2" product="Cloud extension" description="The ability to set custom headers in rewrite rules was added in {product} {ver}." :use-changelog="false" />
131+
132+
You can set arbitrary HTTP headers on any rewritten response by including a key-value map under a `headers` key:
133+
134+
```yml
135+
rewrites:
136+
- pattern:
137+
pathname: '/dist/js/*'
138+
destination: '{artifactBaseUrl}/{request.uri}'
139+
headers:
140+
Access-Control-Allow-Origin: 'https://mydomain.com'
141+
```
142+
143+
Headers are combined with those from the `destination`, overwriting any shared names.

0 commit comments

Comments
 (0)