You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set up a Fastify middleware like to create a cookie. The cookie is created correctly for Fastify routes (/api/todos), but the cookies don't make it to the HTTP response of Astro pages.
My index.ts:
importfastifyCookiefrom'@fastify/cookie';importtype{DefineFastifyRoutes}from'@matthewp/astro-fastify';constdefineRoutes: DefineFastifyRoutes=(fastify)=>{fastify.register(fastifyCookie);fastify.addHook("onRequest",async(request,reply)=>{reply.setCookie("someCookie","someValue");});fastify.get('/api/todos',function(request,reply){reply.send({todos: [{label: 'eat lunch'},{label: 'exercise'},{label: 'walk the dog'}]});});
I've tried adding a console.log to the middleware and it gets printed for both pages, so it seems like reply.setCookie is executed in both cases. Why is the cookie missing from Astro routes HTTP response (I've checked via Chrome Developer Tools)? It seems like a bug? Is there a workaround?
Thanks!
The text was updated successfully, but these errors were encountered:
PeterDraex
changed the title
Can't set cookie on Astro routes
Can't set cookies on Astro routes
Jun 16, 2024
I set up a Fastify middleware like to create a cookie. The cookie is created correctly for Fastify routes (
/api/todos
), but the cookies don't make it to the HTTP response of Astro pages.My
index.ts
:I've tried adding a
console.log
to the middleware and it gets printed for both pages, so it seems like reply.setCookie is executed in both cases. Why is the cookie missing from Astro routes HTTP response (I've checked via Chrome Developer Tools)? It seems like a bug? Is there a workaround?Thanks!
The text was updated successfully, but these errors were encountered: