@@ -46,6 +46,7 @@ http-server --help
4646
4747Name | Short | Long | Description
4848--- | --- | --- | ---
49+ Cross-Origin Resource Sharing | N/A | ` --cors ` | Enable Cross-Origin Resource Sharing allowing any origin
4950Help | N/A | ` --help ` | Prints help information
5051Version | ` -V ` | ` --version ` | Prints version information
5152Verbose | ` -v ` | ` --verbose ` | Prints output to console
@@ -73,7 +74,7 @@ TLS Key Algorithm | N/A | `--tls-key-algorithm` | Algorithm used to generate cer
7374The following are some relevant details on features supported by this HTTP Server
7475solution that may be of the interest of the user.
7576
76- ### TLS Reference
77+ ### TLS (HTTPS)
7778
7879The TLS solution supported for this HTTP Server is built with [ rustls] ( https://github.com/ctz/rustls )
7980crate along with [ hyper-rustls] ( https://github.com/ctz/hyper-rustls ) .
@@ -92,6 +93,34 @@ Run `http-server` as follows:
9293http-server --tls --tls-cert < PATH TO YOUR CERTIFICATE> --tls-key < PATH TO YOUR KEY> --tls-key-algorithm pkcs8
9394```
9495
96+ ### Cross-Origin Resource Sharing (CORS)
97+
98+ This HTTP Server brings support to CORS headers _ out of the box_ .
99+ Based on the headers you want to provide to your HTTP Responses, 2
100+ different methods for CORS configuration are available.
101+
102+ By providing the ` --cors ` option to the ` http-server ` , CORS headers
103+ will be appended to every HTTP Response, allowing any origin.
104+
105+ For more complex configurations, like specifying an origin, a set of allowed
106+ HTTP methods and more, you should specify the configuration via the configuration
107+ TOML file.
108+
109+ The following example shows all the options available, these options are
110+ mapped to the server configuration during initialization.
111+
112+ ``` toml
113+ [cors ]
114+ allow_credentials = false
115+ allow_headers = [" content-type" , " authorization" , " content-length" ]
116+ allow_methods = [" GET" , " PATCH" , " POST" , " PUT" , " DELETE" ]
117+ allow_origin = " example.com"
118+ expose_headers = [" *" , " authorization" ]
119+ max_age = 600
120+ request_headers = [" x-app-version" ]
121+ request_method = " GET"
122+ ```
123+
95124## Release
96125
97126In order to create a release you must push a Git tag as follows
0 commit comments