Skip to content

Commit

Permalink
fix(nginx): 修改nginx配置,修复404页面出现首页问题
Browse files Browse the repository at this point in the history
  • Loading branch information
142vip.cn committed Oct 26, 2023
1 parent 9662072 commit e725c90
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ http {
# root 根目录,默认nginx镜像的html文件夹,可以指定其他
root /usr/share/nginx/html;
index index.html index.htm;
# 如果vue-router使用的是history模式,需要设置这个
try_files $uri $uri/ /index.html;

# # 确保能够处理前端路由,并在找不到对应文件或目录时返回 index.html 文件,让前端应用接管路由处理。
# # 这对于使用前端框架(如 Vue.js、React、Angular 等)开发的单页应用非常有用
# # 如果vue-router使用的是history模式,需要设置这个
# try_files $uri $uri/ /index.html;
}
## 错误页面
error_page 404 /404.html;
Expand Down

0 comments on commit e725c90

Please sign in to comment.