Issue Description
I’m working on an authentication system where my Go backend sends a cookie containing a refresh token after successful login. The problem is that even though I can see the Set-Cookie
header in the browser dev tools, the cookie never gets stored in the browser.
Setup Details
- Client:
https://webapp.example.com
- Backend:
https://backend.example.com
Backend Cookie Implementation (Go)
http.SetCookie(response, &http.Cookie{
Name: "AUTH_TOKEN",
Value: tokenData.RefreshValue,
Expires: time.Now().Add(30 * 24 * time.Hour),
HttpOnly: true,
SameSite: http.SameSiteNoneMode,
Secure: true,
Path: "/",
Domain: "https://webapp.example.com",
})
Frontend API Call (Next.js)
const response = await fetch("https://backend.example.com/token-refresh", {
headers: {
"Content-Type": "application/json",
},
method: "POST",
credentials: "include",
});
What I’ve Checked
- The
Set-Cookie
header shows up correctly in network requests - Cookie has
SameSite=None
andSecure=true
for cross-origin requests - Using
credentials: "include"
in fetch calls
Questions
- Why might the browser refuse to store this cookie?
- What additional configuration might be needed for cross-domain cookie handling?