http-server
http-server copied to clipboard
CORS | Support for multiple origins
Description
Capability to allow several origins, instead of providing wildcard (*
), a list of origins could be configured to be accepted
by the server.
When a request is gathered from the client, the origin is checked against the provided list and if such origin belongs
to the list, then the CORS Allow-Origin
header would have such origin settled as value.
Why is this useful?
This could help for serving files to multiple front-ends but not any
How should this work?
- CORS configuration is provided via TOML config file
- A list of origins is set to the
allowed_origins
list in the configuration file - When a request hits this server, the origin from the HTTP Request is checked against the
allowed_origins
setting 3.1. If the origin of the HTTP Request belongs to the list, theAccess-Control-Allow-Origin
header is set to such origin 3.2. Otherwise theAccess-Control-Allow-Origin
header is not included in the HTTP Response
This feature request was originally mentioned by @morenol in the following PR comment:
https://github.com/EstebanBorai/http-server/pull/7#discussion_r627737889