Fix relative redirects
Setting next.Host before setting next.Path breaks relative redirects on external sites, where next.Host != r.URL.Host.
This commit is contained in:
parent
1975525eeb
commit
6d23d00a6f
1 changed files with 1 additions and 1 deletions
2
main.go
2
main.go
|
@ -426,10 +426,10 @@ func proxyGemini(req gemini.Request, external bool, root *url.URL,
|
||||||
w.Write([]byte(fmt.Sprintf("This page is redirecting you to %s", next.String())))
|
w.Write([]byte(fmt.Sprintf("This page is redirecting you to %s", next.String())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
next.Host = r.URL.Host
|
|
||||||
if external {
|
if external {
|
||||||
next.Path = fmt.Sprintf("/x/%s/%s", next.Host, next.Path)
|
next.Path = fmt.Sprintf("/x/%s/%s", next.Host, next.Path)
|
||||||
}
|
}
|
||||||
|
next.Host = r.URL.Host
|
||||||
next.Scheme = r.URL.Scheme
|
next.Scheme = r.URL.Scheme
|
||||||
w.Header().Add("Location", next.String())
|
w.Header().Add("Location", next.String())
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
|
|
Loading…
Reference in a new issue