-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new
allowedHosts
option (#13278)
Co-authored-by: Armand Philippot <git@armand.philippot.eu> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> Co-authored-by: ArmandPhilippot <59021693+ArmandPhilippot@users.noreply.github.com> Co-authored-by: Eveeifyeve <88671402+Eveeifyeve@users.noreply.github.com> Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com> Co-authored-by: sarah11918 <5098874+sarah11918@users.noreply.github.com> Co-authored-by: Fryuni <11063910+Fryuni@users.noreply.github.com>
- Loading branch information
1 parent
c1d2d25
commit 4a43c4b
Showing
8 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
'astro': minor | ||
--- | ||
|
||
Adds a new configuration option `server.allowedHosts` and CLI option `--allowed-hosts`. | ||
|
||
Now you can specify the hostnames that the dev and preview servers are allowed to respond to. This is useful for allowing additional subdomains, or running the dev server in a web container. | ||
|
||
`allowedHosts` checks the Host header on HTTP requests from browsers and if it doesn't match, it will reject the request to prevent CSRF and XSS attacks. | ||
|
||
```shell | ||
astro dev --allowed-hosts=foo.bar.example.com,bar.example.com | ||
``` | ||
|
||
```shell | ||
astro preview --allowed-hosts=foo.bar.example.com,bar.example.com | ||
``` | ||
|
||
```js | ||
// astro.config.mjs | ||
import {defineConfig} from "astro/config"; | ||
|
||
export default defineConfig({ | ||
server: { | ||
allowedHosts: ['foo.bar.example.com', 'bar.example.com'] | ||
} | ||
}) | ||
``` | ||
|
||
This feature is the same as [Vite's `server.allowHosts` configuration](https://vite.dev/config/server-options.html#server-allowedhosts). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters