Question

Dynamic HTTP Routes for CRA (using react router dom)

Hello

I just deployed my react app with digital ocean. I’m wondering how to add dynamic routes to my HTTP routes.

Currently I’m trying the following YAML configuration but it is not working.

routes:
  - path: /
  - path: /dashboard
  - path: /invoice
  - path: /patient
  - path: /profile
  - path: /patient/[id]

How can I add a dynamic route for (example):

https://mydoapp.com/patient/1
https://mydoapp.com/patient/2
https://mydoapp.com/patient/3

Am I missing something?

Thanks!


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello @wmFish ,

Unfortunately, dynamic routing is not supported in the App Platform as of now. As a workaround, you can set the catch_all settings to index.html file. There are 2 methods to set the catchall_document.

=======

  1. Using Cloud panel UI: Log in and click on App > Settings >> click on component name > scroll down to Custom page > Edit Custom page and select Catchall > Enter index.html in the page name block > save

  2. Using App Spec: You can the catchall_document to index.html in-app spec.

Here’s the documentation link which will help you in updating your app: https://www.digitalocean.com/docs/app-platform/references/app-specification-reference/ https://www.digitalocean.com/docs/app-platform/references/command-line/

=======

A similar discussion can be found in our community channel as well. https://www.digitalocean.com/community/questions/react-router-and-app-platform-problems

Regarding dynamic routing, I encourage you to share your thoughts about this on our ideas page: https://ideas.digitalocean.com/

Hope this helps!

Cheers, Sri Charan