Home > Backend Development > PHP Problem > How to set php to allow cross-domain requests

How to set php to allow cross-domain requests

WJ
Release: 2023-03-01 14:16:02
Original
5600 people have browsed it

How to set php to allow cross-domain requests

How to set php to allow cross-domain requests?

Add

header(“Access-Control-Allow-Origin: *”);
Copy after login

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发起的跨域请求,其他的都不通过
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template