How do I serve nested static content on Heroku?
-
19-04-2021 - |
Question
I have a rails application with static content in the public
directory (e.g. public/index.html
) and additional static content in nested subdirectories (e.g. public/one/two/index.html
).
All the static content is served correctly if I run it locally via script/server
but when I upload it to Heroku the top-level page loads correctly but the nested content returns a 404.
I've found a number of resources (for example this question) which discuss static content in rails but they all seem to assume a fairly simple structure with a single directory containing all the files.
Is there any way I can fix this?
OTHER TIPS
You can serve up static content on Heroku without writing any "code" at all... you just need to tell the "Rack" middleware where the content is (as detailed in this help article):