Replies: 1 comment
-
|
Hey! This is usually related to how youre testing, not gin itself. 1. Domain issue - try empty string: c.SetCookie("TOKEN_JWT", token, maxAge, "/", "", false, true)2. Frontend needs credentials: fetch('/login', {
method: 'POST',
credentials: 'include', // Important!
body: JSON.stringify(data)
});
// or axios
axios.post('/login', data, { withCredentials: true });3. CORS if different ports: import "github.com/gin-contrib/cors"
config := cors.Config{
AllowOrigins: []string{"http://localhost:3000"},
AllowCredentials: true,
}
r.Use(cors.New(config))Debug tip: Check Network tab for Set-Cookie header. If present but cookie not stored, browser is rejecting due to SameSite/Secure issues. Let me know which one fixes it! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I have an error where I am not getting cookies back when making a POST request.
My code:
Return HEAD
But GET request witch cookie - passes
Beta Was this translation helpful? Give feedback.
All reactions