Skip to content

Commit

Permalink
some small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iebb committed May 21, 2022
1 parent 0d52e31 commit 65e154b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 65e154b

Please sign in to comment.