You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-24 15:14:30 +02:00
fixed auto www redirect due to missing schema
This commit is contained in:
@@ -246,9 +246,15 @@ func wwwRedirect(redirectHosts []string) *hook.Handler[*core.RequestEvent] {
|
|||||||
host := e.Request.Host
|
host := e.Request.Host
|
||||||
|
|
||||||
if strings.HasPrefix(host, "www.") && list.ExistInSlice(host, redirectHosts) {
|
if strings.HasPrefix(host, "www.") && list.ExistInSlice(host, redirectHosts) {
|
||||||
|
// note: e.Request.URL.Scheme would be empty
|
||||||
|
schema := "http://"
|
||||||
|
if e.IsTLS() {
|
||||||
|
schema = "https://"
|
||||||
|
}
|
||||||
|
|
||||||
return e.Redirect(
|
return e.Redirect(
|
||||||
http.StatusTemporaryRedirect,
|
http.StatusTemporaryRedirect,
|
||||||
(e.Request.URL.Scheme + "://" + host[4:] + e.Request.RequestURI),
|
(schema + host[4:] + e.Request.RequestURI),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user