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. |
||
---|---|---|
.. | ||
allconfig | ||
privacy | ||
security | ||
services | ||
testconfig | ||
commonConfig.go | ||
commonConfig_test.go | ||
configLoader.go | ||
configLoader_test.go | ||
configProvider.go | ||
configProvider_test.go | ||
defaultConfigProvider.go | ||
defaultConfigProvider_test.go | ||
env.go | ||
env_test.go | ||
namespace.go | ||
namespace_test.go |