user3504982
user3504982

Reputation: 108

React-router doesn't work in my remote environment

I've tried this

React-Router: No Not Found Route?

at my localhost, it works well. But in the remote server, it doesn’t work. when I put "xxx.xxx.xxx.xxx/Welcome " directly on browser , 404 always comes out.

Upvotes: 0

Views: 116

Answers (1)

Yaro
Yaro

Reputation: 58

Please, post router code snippet and webserver config. I assume the problem is nginx/apache not serving index.html properly.

Here i have an example from my working server that serves build version of my react project that uses react-router

server {
    ...
    location / {
        root /home/full_project_directory/build;
        try_files $uri /index.html =404;
    }
    ...
}

The code above catches any path variables and redirects them to index.html, where react-router is able to handle them.

Upvotes: 1

Related Questions