Report this

What is the reason for this report?

React Router with the App Platform

Posted on October 13, 2020

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?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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: https://github.com/snormore/react-router-4-example — and deployed it as a static site app here and a dynamic web service app here.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.