Uniapp 跨域问题 404问题
1.如果发布后路径页面刷新报404
在发行后上传的服务器端nginx配置伪静态
location /m {
try_files $uri $uri/ /m/index.html;
}
2.如果请求的后端做了反向代理
需要在后端nginx反向代理的配置文件添加
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization,Origin,X-Requested-With,
Accept,Referer,Depth,X-File-Size,If-Modified-Since,X-File-Name,X-File-Type,token';
if ($request_method = 'OPTIONS') {
return 204;
}
通过以上方式可实现跨域
