php thinkphp 接口跨域问题 设置了headers 还是报错的解决方案 OPTIONS 跨域
2021-04-01 10:27
标签:hid auth off poi padding access rect isp inter php thinkphp 接口跨域问题 设置了headers 还是报错的解决方案 OPTIONS 跨域 标签:hid auth off poi padding access rect isp inter 原文地址:https://www.cnblogs.com/tolingsoft/p/12571660.htmlif($_SERVER[‘REQUEST_METHOD‘] == ‘OPTIONS‘){
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header(‘Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH‘);
exit;
}
//上面的代码很关键 问题就出在上面这里
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header(‘Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH‘);
x
if($_SERVER[‘REQUEST_METHOD‘] == ‘OPTIONS‘){
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header(‘Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH‘);
exit;
}
//上面的代码很关键 问题就出在上面这里
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header(‘Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH‘);
文章标题:php thinkphp 接口跨域问题 设置了headers 还是报错的解决方案 OPTIONS 跨域
文章链接:http://soscw.com/index.php/essay/70891.html