By Rob Arkins
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!
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.
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.