H
Hono3mo ago
N01R

Cookies doesn't process

When I try to run in my middleware the following
setCookie(c, 'test', 'res', { maxAge: 60 * 60 * 24 * 7, httpOnly: true })
console.log(getCookie(c, 'test'));
setCookie(c, 'test', 'res', { maxAge: 60 * 60 * 24 * 7, httpOnly: true })
console.log(getCookie(c, 'test'));
the result I get is undefined, then randomly after a while when I rerun it shows the cookie, but the cookie never allowed to be deleted or changed and always stays the same.
2 Replies
justboereh
justboereh3mo ago
I don’t know HTTP, but I think setCookie append your value to Set-Cookie header for the browser. You might want to use some sort of context.
N01R
N01R3mo ago
Found the issue now, I returned return new Response(null, { status: 204 }) and for resulted in this issue. as I need to set the headers alongside the status for it to work. solution is to use return c.body('', 204)