fix: cookie logic for chromium (chromium, it's you again)
This commit is contained in:
parent
24bae2ac48
commit
cba26e0c30
1 changed files with 10 additions and 10 deletions
20
main.go
20
main.go
|
@ -66,16 +66,13 @@ func cmain(argc int, argv []string) string {
|
||||||
p1 := r.URL.Path
|
p1 := r.URL.Path
|
||||||
p := strings.Split(p1, "/")[1:]
|
p := strings.Split(p1, "/")[1:]
|
||||||
seg := p[0]
|
seg := p[0]
|
||||||
vc, err := r.Cookie("view")
|
if seg == "" {
|
||||||
if err != nil {
|
fileserver.ServeHTTP(w, r)
|
||||||
w.Header().Add("Set-Cookie", "view="+seg+"; Path=/; SameSite=Strict; HttpOnly")
|
|
||||||
w.Header().Add("Location", p1)
|
|
||||||
w.WriteHeader(http.StatusFound)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v := vc.Value
|
vc, err := r.Cookie("view")
|
||||||
if seg != v {
|
if err == nil && seg != vc.Value {
|
||||||
w.Header().Add("Location", "/"+v+p1)
|
w.Header().Add("Location", "/"+vc.Value+p1)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -140,8 +137,11 @@ func cmain(argc int, argv []string) string {
|
||||||
cmdmap[seg] = conf
|
cmdmap[seg] = conf
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
proxy_path := conf.Proxy + "/" + strings.Join(p[1:], "/")
|
w.Header().Add("Set-Cookie", "view="+seg+"; Path=/; SameSite=Strict; HttpOnly")
|
||||||
proxy(w, r, proxy_path)
|
w.Header().Add("Location", p1)
|
||||||
|
w.WriteHeader(http.StatusFound)
|
||||||
|
// proxy_path := conf.Proxy + "/" + strings.Join(p[1:], "/")
|
||||||
|
// proxy(w, r, proxy_path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileserver.ServeHTTP(w, r)
|
fileserver.ServeHTTP(w, r)
|
||||||
|
|
Loading…
Reference in a new issue