vite2.0+vue3.2 打包后放在nginx上刷新页面404问题
vite2.0+vue3.2 项目 在本地运行没问题,扔到服务器上刷新之后页面404
server
{
listen 80;
index index.html;
root /xxxx/dist;
#vue-router配置
location / {
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
}
以上方法适用于vue2
vue3项目 如下配置 alias 直想打包后的文件夹
server {
listen 4000;
location / {
autoindex on; # 不开启试用alias会403
alias /xxxx/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
# .... 其他配置
}
接口404
vue项目在vue.config.js中设置的有proxy跨域代理,在本地运行没有问题,但是放在服务器上就成了404,可能是打包后vue.config.js中的代理失效,以ngxin的代理为准
vue.config.js配置了proxy代理
// vite 相关配置
server: {
port: 80,
host: true,
open: true,
proxy: {
'/system': {
target: env.VITE_APP_BASE_API,
c