cmd/tailscale: make web mode preserve URL scheme in Synology redirect

Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
pull/4386/head
Xiaochao Dong (@damnever) 3 years ago committed by David Crawshaw
parent 2550acfd9d
commit 7d97800d52

@ -269,15 +269,14 @@ func synoTokenRedirect(w http.ResponseWriter, r *http.Request) bool {
}
// We need a SynoToken for authenticate.cgi.
// So we tell the client to get one.
serverURL := r.URL.Scheme + "://" + r.URL.Host
synoTokenRedirectHTML.Execute(w, serverURL)
_, _ = fmt.Fprint(w, synoTokenRedirectHTML)
return true
}
var synoTokenRedirectHTML = template.Must(template.New("redirect").Parse(`<html><body>
const synoTokenRedirectHTML = `<html><body>
Redirecting with session token...
<script>
var serverURL = {{ . }};
var serverURL = window.location.protocol + "//" + window.location.host;
var req = new XMLHttpRequest();
req.overrideMimeType("application/json");
req.open("GET", serverURL + "/webman/login.cgi", true);
@ -289,7 +288,7 @@ req.onload = function() {
req.send(null);
</script>
</body></html>
`))
`
func webHandler(w http.ResponseWriter, r *http.Request) {
if authRedirect(w, r) {

Loading…
Cancel
Save