mirror of
https://github.com/matrix-org/matrix-spec
synced 2025-12-20 16:38:37 +01:00
Add a host and scheme to Location headers in redirects
Our apache reverse-proxy can't correctly rewrite relative Location headers, so add the Host from the request into the Location.
This commit is contained in:
parent
2c6de16779
commit
f31a053995
|
|
@ -387,8 +387,12 @@ func (s *server) serveSpec(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Write([]byte("Not found"))
|
w.Write([]byte("Not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) redirectTo(w http.ResponseWriter, _ *http.Request, path string) {
|
func (s *server) redirectTo(w http.ResponseWriter, req *http.Request, path string) {
|
||||||
w.Header().Set("Location", path)
|
u := *req.URL
|
||||||
|
u.Scheme = "http"
|
||||||
|
u.Host = req.Host
|
||||||
|
u.Path = path
|
||||||
|
w.Header().Set("Location", u.String())
|
||||||
w.WriteHeader(302)
|
w.WriteHeader(302)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue