【发布时间】:2025-12-02 03:55:01
【问题描述】:
我有一个 react 前端应用程序,它使用 react-router 创建不同的路由。在开发服务器上它工作正常,但是当我构建项目时,它给了我 404,同时直接用不同的路由访问它。网站以xyz.net 完美打开。当我尝试使用xyz.net/login 访问它时,它会给出 404。
这是我的 nginx 配置文件
server {
listen 80;
server_name xyz.net www.xyz.net;
root /root/frontend/react/build/;
index index.html;
location /api/ {
include proxy_params;
proxy_pass http://localhost:8000/;
}
}
【问题讨论】:
-
可能是重复的。见*.com/a/45599233/1397590
标签: reactjs nginx react-router