php代码解决跨域问题
Posted newjueqi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php代码解决跨域问题相关的知识,希望对你有一定的参考价值。
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:OPTIONS, GET, POST, DELETE, PUT");
header("Access-Control-Allow-Credentials:true");
header("Access-Control-Allow-Headers:content-type,Host,Connection,Pragma,Cache-Control,Accept,Access-Control-Request-Method,Access-Control-Request-Headers,Origin,User-Agent,Sec-Fetch-Mode,Sec-Fetch-Site,Sec-Fetch-Dest,Referer,Accept-Encoding,Accept-Language");
header("Allow:OPTIONS, GET, POST, DELETE, PUT");
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS')
echo "ok";
exit();
以上是关于php代码解决跨域问题的主要内容,如果未能解决你的问题,请参考以下文章
PHP解决HTTP和HTTPS跨域共享session的方法及代码实例