React Router with the App Platform

Posted October 13, 2020 2.9k views
ReactDigitalOcean App Platform

I have a React app deployed to the App Platform and am using React Route for navigation. The HTTP Route is set to ’/’. If I navigate away from this route I get a 404 error.... is it possible to get this working? Is there something else I need to enter in for the HTTP Route, like a wildcard ’/*’ for example?

1 comment

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
2 answers

I have problems with React Router and the App Platform, too. Locally everything is fine. On the deployed app, the homepage (route /) works fine, too. All my other routes have problems. If I visit a page i have linked from my homepage it works but if I hit refresh I get a 404. Same if I attempt to directly navigate to /xyz.

I’ve already contacted support but if anyone knows a solution please let me know.

@robarkins 👋

The HTTP route you specify in the app spec for your component represents the prefix of the route path to be matched, not the exact path, so routing to paths underneath this in a React app should work as expected.

As an example, I forked this React Router sample repo: — and deployed it as a static site app here and a dynamic web service app here.

  • Hi @snormoredo

    Thanks for replying.

    The routing is pretty much identical to that example. It works fine locally and I’ve had it deployed to a droplet for the last year.

    I wonder do I have the App configured correctly? I have a service deployed with the HTTP Route ’/api’, then I have a static site component with the Route ’/’. Not sure what the problem could be.

    • Ah interesting. If your repo is public then I can fork and see if I can spot anything from here. Otherwise, I’d suggest reaching out to DO Support with a ticket and we can take a closer look at the app specifically.