diff --git a/login.go b/login.go index 1b562e8..b7e4c6e 100644 --- a/login.go +++ b/login.go @@ -47,8 +47,3 @@ func handleLogin(w http.ResponseWriter, r *http.Request) { _, _ = io.Copy(w, resp.Body) _ = resp.Body.Close() } - -func serverSideLoginRewriter(resp *http.Response) (err error) { - resp.Header.Add("Set-Cookie", "server_side_login=1; Max-Age=86400; Path=/") - return nil -} diff --git a/main.go b/main.go index 95aea51..64e275e 100644 --- a/main.go +++ b/main.go @@ -70,8 +70,13 @@ func main() { staticRemote, _ := url.Parse("https://f1vp.netlify.app") staticProxy := httputil.NewSingleHostReverseProxy(staticRemote) + serverSideLogin := 0 if login != "" && password != "" { - staticProxy.ModifyResponse = serverSideLoginRewriter + serverSideLogin = 1 + } + staticProxy.ModifyResponse = func(resp *http.Response) (err error) { + resp.Header.Add("Set-Cookie", fmt.Sprintf("server_side_login=%d; Max-Age=86400; Path=/", serverSideLogin)) + return nil } staticHandler := func(w http.ResponseWriter, r *http.Request) { log.Printf("%s FE* - %s\n", r.RemoteAddr, r.URL.String())