How to set php to allow cross-domain requests?
Add
header(“Access-Control-Allow-Origin: *”);
to the header of the php file. If you want to set up to allow only a certain website to pass, you can set it like this
header(“Access-Control-Allow-Origin: http://test.com”); // 允许test.com发起的跨域请求,其他的都不通过
Related recommendations: php tutorial
The above is the detailed content of How to set php to allow cross-domain requests. For more information, please follow other related articles on the PHP Chinese website!