I have client deployed on [project_name].vercel.app and server on [project_name]-api.vercel.app
I’m logged in and on frontend side I see httpOnly cookie ‘token’, but then in next request ctx.cookies.get(“token”) returns undefined.
The client and server are on different domains, do I need to add something in vercel configuration?
It works without any issues on localhost, client port 5173, server 4000
I think you’re on the right track but missing some of the configurations. This is not a Vercel issue but more of a web standards thing:
Could you share the code where you set the cookie? By default, your web server will set the cookie on the same domain the request was received. I think your configuration for SameSite or domain is the issue.
I found this insightful discussion on Reddit on this topic. In addition to this, I’d recommend reading up on the Using HTTP cookies - HTTP | MDN for cross domain cookies.
Thank you for the reply:
I use koa for the api and when I set a cookie: ctx.cookies.set("token", token);
I see the cookie in the browser with httpOnly true flag, but when I tried to add SameSite config: ctx.cookies.set("token", token, { sameSite: "none", });
The cookie is not created in the browser.