Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at url

It's the very famous browser error. I know it has been discussed a lot but I've noticed is a very generic error so I want to present my problem.

I am making simple requests (get,post) on a server where I have access. My browsers (chrome, firefox) give me Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at url (Reason: CORS header 'Access-Control-Allow-Origin' does not match 'null'). error.

When I use some of (hacking)plugins I get the responses fine.

What I've tried is to add on my back-end (on server):

header('Access-Control-Allow-Origin: *');

in index.php file with no luck. Any other ideas ?

like image 314
korteee Avatar asked Sep 20 '25 15:09

korteee


1 Answers

Try adding

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
like image 135
ddepablo Avatar answered Sep 22 '25 03:09

ddepablo