Nginx反向代理Vue3等接口解决跨域问题
#vue3 nginx 代理
location ^~ /apis/ {
rewrite "^/apis/(.*)$" /$1 break;
#proxy_set_header Host $http_host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header REMOTE-HOST $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Public-Network-URL http://$http_host$request_uri;
proxy_pass http://IP:端口;#后端地址
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#vue3 刷新后404
location / {
try_files $uri $uri/ /index.html;
}