[英]404 NOT found ngnix error when refrehsing page
刷新应用程序时出现错误 404 not found ngnix。 如果我第一次重新启动并且能够路由到不同的页面,直到我直接刷新我的页面,我的应用程序似乎工作正常。
这似乎是一个 ngnix 问题,因为在构建前端后运行本地主机时它工作正常。 我注意到其他人有问题,他们能够通过添加try_file $uri /index.html
来解决他们的问题,但我已经提前提出了,但仍然遇到这个问题
location / {
root /boost/server/build;
index index.html
try_file $uri /index.html;
}
location /api/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://my_public_ip;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
任何帮助,将不胜感激
您应该在 index.html 之后使用分号。 像这样
location / {
root /boost/server/build;
index index.html;
try_files $uri /index.html;
}
或者这样
location / {
root /boost/server/build;
set $fallback_file /index.html;
if ($http_accept !~ text/html) {
set $fallback_file /null;
}
try_files $uri $fallback_file;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.