I have a react app I have built and deployed to DigitalOcean App platform. I am wondering if there is a wild card I can use for http request routes. I am able to set paths for subdirectories but I can't figure out how to set up paths for a subdirectory with post ID.
For example:
mywebsite.com/subdirectory -> works and I can access this page
mywebsite.com/subdirectory/12345 -> This doesn't work when I add an ID after the subdirectory.
Is there a wildcard or something I can use for accessing specific pages with a subdirectory and ID.
Thank you
To directly answer your question: No, it seems like wildcards are not supported by DO directly (at least not yet). It's not a common design to have wildcards directly in React app. Usually you have an index page and an in-browser router or a backend router of sorts.
If this is the case and you have a browser router, it means you don't actually have multiple pages, you just have an index.html, so you can just setup a Catchall to
index.html
. Any subpage will be redirected to that page, and then your browser router will render proper components and such. See DigitalOcean Web-Site for an explanation.Second case is that you do need a complex routing, which will load a different HTML file where you need it. In this case it would be better to deploy in a container with something like an nginx front.
In this case you would have a Dockerfile that looks something like this:
And deploy it as a service with Dockerfile. See DO's site for exact instructions how to deploy a docker container. (Link to Digital Ocean Docs)