#Astro with vercel doesn't send Set-Cookie with Astro.cookies in production

1 messages · Page 1 of 1 (latest)

exotic canyon
#

So I'm using Astro.cookies to set cookies. In local enviroment it works, but in production @ vercel it doesn't. There isn't even Set-Cookie header

#
---
import {cookieOptions, validYear} from "../../utils"
const params = Astro.url.searchParams
if (!params.has("year") || !validYear(params.get("year"))) {
    return Astro.redirect('/select/year?redirect_reason=invalid.year')
}
Astro.cookies.set("last", Astro.url.href, cookieOptions)
return Astro.redirect("/events/"+params.get("year"))
---
#

In dev enviroment everything works well. The cookie get's send, but @ vercel it doesn't.

exotic canyon
#

I use the latest astro version

heavy roost
#

Did you check the content of "Astro.url.href" in prod ? 🤔

exotic canyon
#

Everything is well, there just isn't any Set-Cookie header

#

Even with the login cookie, just nada

heavy roost
#

how about your cookieOptions ? an example fail reason is if you want it to be secure without having an https connection.
Let's say, you need to cluster two examples like a sandwitch, one that works in a simple dev env, and one that does not. Then try to mmake both projects look identical.
The best way to get help is if you share a github repo with minimal example that reproduces the issue, that way it avoids need to be asking many detailed questions. Sometimes, there could be a bug, thene filing an issue requires a proof with the minimal example and it will get fixed.

plucky pagoda
#

@exotic canyon did you managed to get this work?

exotic canyon
#

Not yet

#

I'm not home