TP接口 前端vue调用出现跨域

出现跨域的解决方式

1.当预处理请求options失败代码报错  会出现跨域cors,排查错误代码

2.设置路由跨域  Route::GET('search/list', 'Index/list')->allowCrossDomain();

 

3.在nginx中

location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Headers' '*';
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}

posted @ 2023-12-06 17:37  东方素  阅读(103)  评论(0)    收藏  举报