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
* Small typo fix of commas
* Also expose if cors header is allowed
* WIP: add cors support to cors option
* Add rough support in code for expose-headers
* Add cors expose option to man page template
* Fix tests to handle expose cors
* Add doc updates for SERVER_CORS_EXPOSE_HEADERS
Copy file name to clipboardExpand all lines: docs/content/configuration/environment-variables.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,9 @@ Specify an optional CORS list of allowed origin hosts separated by commas. Host
57
57
### SERVER_CORS_ALLOW_HEADERS
58
58
Specify an optional CORS list of allowed HTTP headers separated by commas. It requires `SERVER_CORS_ALLOW_ORIGINS` to be used along with. Default `origin, content-type`.
59
59
60
+
### SERVER_CORS_EXPOSE_HEADERS
61
+
Specify an optional CORS list of exposed HTTP headers separated by commas. It requires `SERVER_CORS_ALLOW_ORIGINS` to be used along with. Default `origin, content-type`.
62
+
60
63
### SERVER_COMPRESSION
61
64
`Gzip`, `Deflate` or `Brotli` compression on demand determined by the `Accept-Encoding` header and applied to text-based web file types only. See [ad-hoc mime-type list](https://github.com/joseluisq/static-web-server/blob/master/src/compression.rs#L20). Default `true` (enabled).
The server also supports a list of [CORS exposed headers to scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) separated by commas.
45
+
46
+
This feature depends on `--cors-allow-origins` to be used along with this feature. It can be controlled by the string `--cors-expose-headers` option or the equivalent [SERVER_CORS_EXPOSE_HEADERS](./../configuration/environment-variables.md#server_cors_expose_headers) env.
47
+
48
+
!!! info "Tips"
49
+
- The default exposed headers value is `origin, content-type`.
50
+
- The server also supports [preflight requests](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) via the `OPTIONS` method. See [Preflighted requests in CORS](./../http-methods/#preflighted-requests-in-cors).
Copy file name to clipboardExpand all lines: docs/man/static-web-server.1.rst
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,10 +39,13 @@ Gzip, Deflate or Brotli compression on demand determined by the Accept-Encoding
39
39
Server TOML configuration file path [env: SERVER_CONFIG_FILE=]
40
40
41
41
-j, --cors-allow-headers <cors-allow-headers>::
42
-
Specify an optional CORS list of allowed headers separated by comas. Default "origin, content-type". It requires ``--cors-allow-origins`` to be used along with [env: SERVER_CORS_ALLOW_HEADERS=] [default: origin, content-type]
42
+
Specify an optional CORS list of allowed headers separated by commas. Default "origin, content-type". It requires ``--cors-allow-origins`` to be used along with [env: SERVER_CORS_ALLOW_HEADERS=] [default: origin, content-type]
43
43
44
44
-c, --cors-allow-origins <cors-allow-origins>::
45
-
Specify an optional CORS list of allowed origin hosts separated by comas. Host ports or protocols aren't being checked. Use an asterisk (*) to allow any host [env: SERVER_CORS_ALLOW_ORIGINS=] [default: ]
45
+
Specify an optional CORS list of allowed origin hosts separated by commas. Host ports or protocols aren't being checked. Use an asterisk (*) to allow any host [env: SERVER_CORS_ALLOW_ORIGINS=] [default: ]
46
+
47
+
--cors-expose-headers <cors-expose-headers>::
48
+
Specify an optional CORS list of exposed headers separated by commas. Default "origin, content-type". It requires ``--cors-expose-origins`` to be used along with [env: SERVER_CORS_EXPOSE_HEADERS=] [default: origin, content-type]
46
49
47
50
-z, --directory-listing <directory-listing>::
48
51
Enable directory listing for all requests ending with the slash character (‘/’) [env: SERVER_DIRECTORY_LISTING=] [default: false]
Copy file name to clipboardExpand all lines: src/settings/cli.rs
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ pub struct General {
76
76
default_value = "",
77
77
env = "SERVER_CORS_ALLOW_ORIGINS"
78
78
)]
79
-
/// Specify an optional CORS list of allowed origin hosts separated by comas. Host ports or protocols aren't being checked. Use an asterisk (*) to allow any host.
79
+
/// Specify an optional CORS list of allowed origin hosts separated by commas. Host ports or protocols aren't being checked. Use an asterisk (*) to allow any host.
80
80
pubcors_allow_origins:String,
81
81
82
82
#[structopt(
@@ -85,9 +85,17 @@ pub struct General {
85
85
default_value = "origin, content-type",
86
86
env = "SERVER_CORS_ALLOW_HEADERS"
87
87
)]
88
-
/// Specify an optional CORS list of allowed headers separated by comas. Default "origin, content-type". It requires `--cors-allow-origins` to be used along with.
88
+
/// Specify an optional CORS list of allowed headers separated by commas. Default "origin, content-type". It requires `--cors-allow-origins` to be used along with.
89
89
pubcors_allow_headers:String,
90
90
91
+
#[structopt(
92
+
long,
93
+
default_value = "origin, content-type",
94
+
env = "SERVER_CORS_EXPOSE_HEADERS"
95
+
)]
96
+
/// Specify an optional CORS list of exposed headers separated by commas. Default "origin, content-type". It requires `--cors-expose-origins` to be used along with.
0 commit comments