-->

PHP资讯

您的当前位置:首页 > 资讯 > thinkphp框架

解决tp框架对接axios跨域问题

2022-02-11 14:04:16  来源:admin 点击:870

跨域问题设置请求头
$web = request()->header('Origin');
//跨域请求设置
header("Access-Control-Request-Method:GET,POST");
header("Access-Control-Allow-Credentials:true");
header("Access-Control-Allow-Origin:".$web);
header("Access-Control-Allow-Headers:token,Content-Type, Authorization, Accept, Range, Origin,Token,Lang,lang");
if($this->request->isOptions()){
    exit;
}
这是跟vue或者angualr对接的用的.


和jquery时

header('Access-Control-Allow-Origin: *');

header("Access-Control-Allow-Headers: token,Origin, X-Requested-With, Content-Type, Accept");

header('Access-Control-Allow-Methods: POST,GET');


相关文章更多 >

© 2024版权所有 水水网

电话:171780793