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

Loading…
Cancel
Save