You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New options:
* `FromHeaders`: Server header matching for redirects
* `FromRe`: Regexp with group support, i.e. it replaces $1, $2 in To with the group matches.
Note that if both `From` and `FromRe` is set, both must match.
Also
* Allow redirects to non HTML URLs as long as the Sec-Fetch-Mode is set to navigate on the request.
* Detect and stop redirect loops.
This was all done while testing out InertiaJS with Hugo. So, after this commit, this setup will support the main parts of the protocol that Inertia uses:
```toml
[server]
[[server.headers]]
for = '/**/inertia.json'
[server.headers.values]
Content-Type = 'text/html'
X-Inertia = 'true'
Vary = 'Accept'
[[server.redirects]]
force = true
from = '/**/'
fromRe = "^/(.*)/$"
fromHeaders = { "X-Inertia" = "true" }
status = 301
to = '/$1/inertia.json'
```
Unfortunately, a provider like Netlify does not support redirects matching by request headers. It should be possible with some edge function, but then again, I'm not sure that InertiaJS is a very good fit with the common Hugo use cases.
But this commit should be generally useful.
// There are some tricky infinite loop situations when dealing
392
-
// when the target does not have a trailing slash.
393
-
// This can certainly be handled better, but not time for that now.
394
-
returnServer{}, fmt.Errorf("unsupported redirect to value %q in server config; currently this must be either a remote destination or a local folder, e.g. \"/blog/\" or \"/blog/index.html\"", redir.To)
0 commit comments