fix: fix cookie redirect logic again
This commit is contained in:
parent
cba26e0c30
commit
72c2044a8d
1 changed files with 6 additions and 1 deletions
7
main.go
7
main.go
|
@ -67,16 +67,21 @@ func cmain(argc int, argv []string) string {
|
|||
p := strings.Split(p1, "/")[1:]
|
||||
seg := p[0]
|
||||
if seg == "" {
|
||||
w.Header().Add("Set-Cookie", "view=; Path=/; SameSite=Strict; HttpOnly")
|
||||
w.Header().Add("Cache-Control", "no-store")
|
||||
fileserver.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
vc, err := r.Cookie("view")
|
||||
if err == nil && seg != vc.Value {
|
||||
if err == nil && seg != vc.Value && vc.Value != "" {
|
||||
w.Header().Add("Location", "/"+vc.Value+p1)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
return
|
||||
}
|
||||
if conf, ok := cmdmap[seg]; ok {
|
||||
if err != nil || vc.Value == "" {
|
||||
w.Header().Add("Set-Cookie", "view="+seg+"; Path=/; SameSite=Strict; HttpOnly")
|
||||
}
|
||||
proxy_path := conf.Proxy + "/" + strings.Join(p[1:], "/")
|
||||
proxy(w, r, proxy_path)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue