Answer the question
In order to leave comments, you need to log in
Why doesn't CORS work in php?
Please help me figure it out, I'm at an impasse.
Created a file /var/www/test/index.php.
Added it to nginx so that it can be accessed by test.local .
Created an index.html file that accesses test.local via AJAX.
I get an error that you can not contact a third-party domain.
Okay, really not, because there are no headers.
I put headers in index.php:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization, Access-Control-Allow-Methods, Access-Control-Request-Headers');
echo 'test';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question