I'm using .htaccess to rewrite urls and I used html base tag in order to make it work.
Now, when I try to make an ajax request I get the following error:
XMLHttpRequest cannot load
http://www.example.com/login.php
. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com
' is therefore not allowed access.
Use addHeader
Instead of using setHeader
method,
response.addHeader("Access-Control-Allow-Origin", "*");
*
in above line will allow access to all domains
.
For allowing access to specific domain only
:
response.addHeader("Access-Control-Allow-Origin", "http://www.example.com");
Check this blog post
.