React Router BrowserRouter leads to “404 Not Found - nginx ” error when going to subpage directly without through a home-page click

后端 未结 5 980
旧巷少年郎
旧巷少年郎 2020-12-05 00:10

I am using React Router for routing for a multi-page website. When trying to go to a sub page directly https://test0809.herokuapp.com/signin you\'d get a \"404 Not Found -ng

5条回答
  •  北海茫月
    2020-12-05 00:58

    Just simply add try_files $uri $uri/ /index.html; to location / block in NGINX configuration file like this:

    server {
       listen       80;
       server_name  localhost;
    
       location / {
           root   /build;
           index  index.html;
           try_files $uri $uri/ /index.html;
       }
    }
    

提交回复
热议问题