Home php How to set up PHP on CORS

How to set up PHP on CORS




I work for the first time with React, I try to send a request to my server from React application but the server does not respond:

As I understand it is necessary to configure the server on Cors , Backend I have OpenCart I use Tips of good people does not help write to the script:

Header (‘Access-Control-Allow-Origin: *’);

Header (‘Access-Control-Allow-Methods: Get, Post’);

Header (“Access-Control-Allow-Headers: X-Requested-WITH”);

How to be? How to figure out?

Answer 1

decided this problem, friends for some reason, no one reminded me of http It turns out the necessary protocol T, E HTTPS and in the initial file index.php Headers:

header ('access-control-allow-origin: *');
Header ('Access-Control-Allow-Methods: Get, Post');
Header ("Access-Control-Allow-Headers: X-Requested-WIT");

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions