I have read quite a lot of posts but none of them worked though.
I have ec2 setup in aws installed with ubuntu 16.04 and nginx. went into the site-available
/ site-enabled
to 'Access-Control-Allow-Origin'
allowing one domain access, but how can I add more than one domain access?
I would get multiple values error if I add more than one accress. Lots posts are about php such as
NGINX 'Access-Control-Allow-Origin' header contains multiple values
even though I am not using php but I have tried using the code above but does not work though.
is anyone able to give me a hand or direct me how this can be done on server?
Thanks in advance.
You can conditionally cause the
Access-Control-Allow-Origin
response header to be sent, with the right value, by adding something like the following to your nginx config.That’ll cause
Access-Control-Allow-Origin: https://some.allowed.origin
to be sent if the value of theOrigin
request header in the request ishttps://some.allowed.origin
, and will causeAccess-Control-Allow-Origin: https://another.allowed.origin
to be sent if theOrigin
ishttps://another.allowed.origin
, etc.And if the value of the
Origin
request header is neitherhttps://some.allowed.origin
orhttps://another.allowed.origin
, then noAccess-Control-Allow-Origin
would be sent.