Open stephanrenggli opened 1 year ago
Hi :wave: Thanks for the report, I don't think that is supported (yet) in goStatic. Would you like to contribute back this feature?
Yes, will try to get it working on the weekend.
Feel free to ping me if needed
So I tried a few things but I haven't found a solution that I think is good/works yet. Here's the ideas I had:
But I feel like I may be way off path, so hints would be appreciated.
Edit: Might have a new idea:
Split requestPath at '/' and remove parts of the requestPath until the requestPath exists on the filesystem. This way nothing would have to be hardcoded and and as soon as the requested file exists it could be served.
Lets say the request is example.com/test/doesnotexist/css/404.css
.
On the first iteration the file requested would be /test/doesnotexist/css/404.css
.
On the second iteration the file requested would be /doesnotexist/css/404.css
.
On the third iteration the file requested would be /css/404.css
. This file actually exists and could be served.
I use goStatic in a docker/traefik setup where goStatic serves as errorpages and a catch-all. So any route that isn't matched by traefik will get routed to goStatic. The setup works well.
Traefik will handle:
doesnotexist.example.com
The goStatic fallback will handle:doesnotexist.example.com/doesnotexist
The only case which currently isn't being handled nicely is:
doesnotexist.example.com/doesnotexist/doesnotexist
(or even more subdirs). If there are multiple subdirectories the html page will be shown, but any css/js/images will fail to load.I have tried both setting
-fallback /index.html
and-fallback index.html
, the result seems to be the same. My file structure inside the container looks as follows:Is there a way to redirect all requests to a specified path and not just one level of subdirectories? Am I missing something else?