1

I need to be able to land on a page to validate the user email and to let them change the password based on a token sent by email, so I tried adding a react router like:

<Route exact path="/" component={Home} />
<Route exact path="/users" component={About} />
<Switch>
   <Route exact path="/users/activation" component={About} />
   <Route exact path="/users/recoverpassword" component={About} />
   <Route exact path="/users/activation/:atoken" component={Activation} />
   <Route exact path="/users/recoverpassword/:ptoken" component={PasswordRecovery} />
</Switch>

But it only works if I land on initial page website.com/ page first and go to /users than to /users/activation and than to /users/activation/123

If I land straight on /users/activation/123 it shows nginx 404

404 Not Found
nginx/1.4.6 (Ubuntu)

Not sure yet if its related to nginx cache, service-worker.js or to the router it self.

How can I have multiple landing routers?

Gil Beyruth
  • 598
  • 1
  • 6
  • 11
  • 1
    Looks like a problem with nginx setup. Have a look at [this question](https://stackoverflow.com/questions/43951720/react-router-and-nginx). – FK82 Aug 04 '18 at 11:08
  • Thanks a lot @FK82, adding this to my default config of nginx solved the issue: `location / { try_files $uri /index.html; }` – Gil Beyruth Aug 04 '18 at 13:45

2 Answers2

1

It should be the issue with nginx cache or configuration. Try modifying it NGINX.

0

You can try this

     <BrowserRouter  >
                     <Route push={true} path="/users/activation/:atoken" component={Activation}/> 
      </BrowserRouter>
Sagar Roy
  • 433
  • 4
  • 12