Skip to content

Commit 603dd5c

Browse files
orteth01skipjack
authored andcommitted
docs(config): add allowedHosts to dev-server docs (#1294)
1 parent 468124d commit 603dd5c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: content/configuration/dev-server.md

+29
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ contributors:
66
- skipjack
77
- spacek33z
88
- charlespwd
9+
- orteth01
910
---
1011

1112
webpack-dev-server can be used to quickly develop an application. See the ["How to Develop?"](/guides/development) to get started.
@@ -46,6 +47,34 @@ W> Be aware that when [exporting multiple configurations](/configuration/configu
4647
T> If you're having trouble, navigating to the `/webpack-dev-server` route will show where files are served. For example, `http://localhost:9000/webpack-dev-server`.
4748

4849

50+
## `devServer.allowedHosts`
51+
52+
`array`
53+
54+
This option allows you to specify a whitelist of hosts that are allowed to access the dev server.
55+
56+
```js
57+
allowedHosts: [
58+
'host.com',
59+
'subdomain.host.com',
60+
'subdomain2.host.com',
61+
'host2.com'
62+
]
63+
```
64+
65+
Mimicking django's `ALLOWED_HOSTS`, a value beginning with `.` can be used as a subdomain wildcard. `.host.com` will match `host.com`, `www.host.com`, and any other subdomain of `host.com`.
66+
67+
```js
68+
// this achieves the same effect as the first example
69+
// with the bonus of not having to update your config
70+
// if new subdomains need to access the dev server
71+
allowedHosts: [
72+
'.host.com',
73+
'host2.com'
74+
]
75+
```
76+
77+
4978
## `devServer.clientLogLevel`
5079

5180
`string`

0 commit comments

Comments
 (0)