Answer the question
In order to leave comments, you need to log in
go. Why does it redirect to "/"?
If a redirect response arrives on a request to a specific url, then this redirect will now always be returned when this url is accessed.
Even if you restart the program, nothing will change.
It doesn't even get to the handler.
The redirect response is tied to the current browser session.
In a new incognito window, this url will work until redirected.
There is no middleware, gin, but even without it, the same shnyag.
If I change a certain cookie, then I can log in again.
What could be the problem?
Answer the question
In order to leave comments, you need to log in
https://en.wikipedia.org/wiki/List_of_status_codes...
If in stealth, then the difference is only in the nuances.
I did this for myself:
package tmpl
import (
"net/http"
)
func Redirect(w http.ResponseWriter, address string) {
if address == "" {
address = "/"
}
w.Header().Set("Location", address)
w.Header().Set("Cache-Control", "private, no-store, max-age=0, must-revalidate")
w.WriteHeader(303) // see https://ru.wikipedia.org/wiki/Список_кодов_состояния_HTTP#303
}
It depends on which redirect code you are using.
301 Moved Permanently - this is a permanent redirect, the browser will cache it and will constantly use it, apparently, you are using it.
302 Found is a temporary redirect for one-time redirects. Try to use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question