前端项目部署到nginx访问,登录可以正常访问,浏览器一刷新nginx就提示404
解决办法:nginx 中加入下面两个配置 try_files 和location @router{} 中的东西。

location / {		
    root   spa;
    #1、加入下面这行
    try_files $uri $uri/ @router;
    index  index.html index.htm;
}
#2、加入这个配置
location @router {
    rewrite ^.*$ /index.html last;
}
Logo

前往低代码交流专区

更多推荐