Uniapp跨域之nginx配置
作者:langdi 来源:ytt 发布时间:2022-03-25 22:26:00
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; }
来实现跨域