Skip to content

Commit 4c3a8fa

Browse files
ci: update configuration reference docs (withastro#12534)
Co-authored-by: sarah11918 <[email protected]>
1 parent 3fae562 commit 4c3a8fa

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/content/docs/en/reference/configuration-reference.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,44 @@ one of the following `content-type` headers: `'application/x-www-form-urlencoded
409409

410410
If the "origin" header doesn't match the `pathname` of the request, Astro will return a 403 status code and will not render the page.
411411

412+
#### security.allowedDomains
413+
414+
<p>
415+
416+
**Type:** `Array<RemotePattern>`<br />
417+
**Default:** `[]`<br />
418+
<Since v="5.14.2" />
419+
</p>
420+
421+
Defines a list of permitted host patterns for incoming requests when using SSR. When configured, Astro will validate the `X-Forwarded-Host` header
422+
against these patterns for security. If the header doesn't match any allowed pattern, the header is ignored and the request's original host is used instead.
423+
424+
This prevents host header injection attacks where malicious actors can manipulate the `Astro.url` value by sending crafted `X-Forwarded-Host` headers.
425+
426+
Each pattern can specify `protocol`, `hostname`, and `port`. All three are validated if provided.
427+
The patterns support wildcards for flexible hostname matching:
428+
429+
```js
430+
{
431+
security: {
432+
// Example: Allow any subdomain of example.com on https
433+
allowedDomains: [
434+
{
435+
hostname: '**.example.com',
436+
protocol: 'https'
437+
},
438+
{
439+
hostname: 'staging.myapp.com',
440+
protocol: 'https',
441+
port: '443'
442+
}
443+
]
444+
}
445+
}
446+
```
447+
448+
When not configured, `X-Forwarded-Host` headers are not trusted and will be ignored.
449+
412450
### vite
413451

414452
<p>

0 commit comments

Comments
 (0)