Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin
header?
I'm aware of the *
, but it is too open. I really want to allow just a couple domains.
As an example, something like this:
Access-Control-Allow-Origin: http://domain1.example, http://domain2.example
I have tried the above code but it does not seem to work in Firefox.
Is it possible to specify multiple domains or am I stuck with just one?
For multiple domains, in your
.htaccess
:PHP code example for matching subdomains.
If you are having trouble with fonts, use:
Here's a solution for Java web app, based the answer from yesthatguy.
I am using Jersey REST 1.x
Configure the web.xml to be aware of Jersey REST and the CORSResponseFilter
Here's the code for CORSResponseFilter
We can also set this in Global.asax file for Asp.net application.
Here is what i did for a PHP application which is being requested by AJAX
If the requesting origin is allowed by my server, return the
$http_origin
itself as value of theAccess-Control-Allow-Origin
header instead of returning a*
wildcard.