代理失效是因为 vue-config.js的代理只在本地生效 ngnix需要冲洗配置
location ^~/prod-api/ {
proxy_pass https://gb.***.cn/; #及得结尾的 /
}
404参考
vue项目部署后刷新页面404的原因和解决方案_vue打包后刷新404-CSDN博客
如何解决404问题
1.直接使用hash模式无404问题;
new Router({
mode: 'hash',
...
})
2.使用history模式需服务器进行配置,以下是服务器配置;
new Router({
mode: 'history',
...
})
Nginx:
location / {
…
try_files $uri $uri/ /index.html; ---解决页面刷新404问题
}