Question

React routes not working on Droplets

Posted August 18, 2021 123 views
ReactDigitalOcean Droplets

I deployed my static web app follow this guide:

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-react-application-with-nginx-on-ubuntu-20-04

But routes not working, sub page can’t access.
ex: yourdomain/about or yourdomain/contact with error: 404 Not Found.

I found some similar topics but they do it with the App Platform not with Droplets

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

I believe that you need to have your / location set to the following in order for the routes to work:

location / {
  try_files $uri /index.html;
}

If this still does not work, could you share your whole Nginx server block here?

Regards,
Bobby