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
|
||||
p := strings.Split(p1, "/")[1:]
|
||||
seg := p[0]
|
||||
vc, err := r.Cookie("view")
|
||||
if err != nil {
|
||||
w.Header().Add("Set-Cookie", "view="+seg+"; Path=/; SameSite=Strict; HttpOnly")
|
||||
w.Header().Add("Location", p1)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
if seg == "" {
|
||||
fileserver.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
v := vc.Value
|
||||
if seg != v {
|
||||
w.Header().Add("Location", "/"+v+p1)
|
||||
vc, err := r.Cookie("view")
|
||||
if err == nil && seg != vc.Value {
|
||||
w.Header().Add("Location", "/"+vc.Value+p1)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
@ -140,8 +137,11 @@ func cmain(argc int, argv []string) string {
|
|||
cmdmap[seg] = conf
|
||||
break
|
||||
}
|
||||
proxy_path := conf.Proxy + "/" + strings.Join(p[1:], "/")
|
||||
proxy(w, r, proxy_path)
|
||||
w.Header().Add("Set-Cookie", "view="+seg+"; Path=/; SameSite=Strict; HttpOnly")
|
||||
w.Header().Add("Location", p1)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
// proxy_path := conf.Proxy + "/" + strings.Join(p[1:], "/")
|
||||
// proxy(w, r, proxy_path)
|
||||
return
|
||||
}
|
||||
fileserver.ServeHTTP(w, r)
|
||||
|
|
Loading…
Reference in a new issue