3 ms·
> access-control-allow-origin: The list of origins allowed to make requests. Is it really a list? AFAIK, and according to MDN: "Only a single origin can be spe
by myfonj 5y ago
> access-control-allow-origin: The list of origins allowed to make requests.
Is it really a list? AFAIK, and according to MDN: "Only a single origin can be specified."
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Ac...
- stephenmcirl77 5y agoYep, that's correct. Only a single origin is supported. The implementation on the backend server/proxy may use a lookup list, and return the specified origin if that exists in the list. As called out in the post too, * is a valid one (as is null) but is not recommended.
- rndgermandude 5y agoYou're correct, it's not a list. A browser will sent an Origin header during the OPTIONS preflight that the server can check and then return back that value in an Access-Control-Allow-Origin response header, or it can return * without any checks if e.g. it's a public API endpoint anyway and expected to be hit by fetch/XHR traffic from all kinds of places. Non-browser clients (and browser for non-CORS and/or "simple" requests) will not usually send any CORS headers and preflight requests, so you should account for that when building a web API. Non-browser clients can of course just fake any browser header and request they want, so the Access-Control headers are NOT a substitute for real access control/authentication.