I want to say that I am familiar with this thread that discusses something similar. My question has one nuance that I don't believe is resolved there.
I have a static site deployed to RStudio Connect from Git that runs a React app totally fine, with the exception of "routing". The manifest used to deploy from Git has appmode
set to static
, primary_html
set to a single index.html
, and content_category
set to site
.
The React routing library used generally doesn't reload the page on navigation, and so the app works totally fine until you refresh on a route that is not just the Content URL, in which case you get a 404. My React routing library thankfully makes it easy to prepend all links with the RS Connect Content URL for the app (e.g., what would normally be site.com/route1/route1b
, can easily be changed to site.com/contenturl/route1/route1b
), so the URL is formatted the way I would expect but I still get the 404, and I suspect this is a (very reasonable) limitation on deploying static sites.
Context out of the way, I have two questions:
- is the behavior I observed normal (404 instead of serving
index.html
at some route that does not match static content)? - If 1. is normal is there a way native to RS Connect to have it always serve
index.html
at any route that starts with/contenturl
except when the path resolves to some static content?
Example:
Homepage is at
site.com/contenturl
.I want to see some performance statistics, so I click a link and go to
site.com/contenturl/stats
.
This page renders fine, since its a single-page app and JS routing does not refresh and handles this
itself.I bookmark this page because I go to it often.
The next day, I come back and click my bookmark and get a 404.
I believe I could just serve these files from FastAPI with a custom route to achieve what I described above, but for the sake of separation I figured it would be nice to take advantage of the static serving options offered by RS Connect.
Thanks in advance for any help.