Add development server SPA support - url rewriting
When building SPA's I often want to have some sort of route like https://<website>/foo/<id>. This page will often use javascript to pull in the relevant data. In my production config I have the webserver route those requests to the index.
However, when working locally using hugo server this doesn't seem possible. I have to either overwrite the 404 page or try and use a fake ID which ends up with custom logic and becomes tricky to deal with.
I would like to be able to do something like:
[[server.spa]]
from = "/foo/**"
to = "/foo/index.html"
Meaning that all my requests to foo are redirected to the index. This means the JS would then be able to call that object but my local dev hugo frontend end will be able to just render the static index html file.
This would allow me to work locally on the pages that need to support dynamic content/call out via javascript. It would not affect the generated content from hugo build.
Source: gohugoio/hugo