Question

React Router with the 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?

Subscribe
Share

@robarkins did you get this resolved?

Thanks


Submit an 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.