From 74544ee6fe85f1c95d73b95f502050e452460b50 Mon Sep 17 00:00:00 2001 From: "142vip.cn" Date: Thu, 26 Oct 2023 17:53:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20=E4=BF=AE=E6=94=B9nginx=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E4=BF=AE=E5=A4=8D404=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=A6=96=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index 44ce49d..6eb8641 100644 --- a/nginx.conf +++ b/nginx.conf @@ -29,8 +29,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;