-
I'm setting a cookie from the pages/api/login.ts
pages/Home.tsx
Am I missing any configuration to get an HTTP-Only cookie inside When I make the same API call for authentication check pages/api/user.ts
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi, I have a bunch of apps that do this, and it works flawlessly so I am gonna guess we are missing something here, as usual with cookies, you have to squint hard to see where the error is. While I setup a reproduction demo, could you please try with setting a path to the cookie? with this value: EditAlright, just did some testing, and the res.setHeader(
"set-cookie",
serialize("tomato", "foo-bar", { path: "/", httpOnly: true })
); Here's a video by Feross, from his Web Security course explaining the Path better than I can |
Beta Was this translation helpful? Give feedback.
-
I have the same issue nextjs SSR returning no cookies in ctx.req.cookies and ctx.req.headers My express server : Nextjs ssr: `export const getServerSideProps: GetServerSideProps<{ data: HomePagePropData }> = async (context ) => { const res = await fetch( if (!res.ok) { let user = await res.json() as User; return { }` Everything works fine in development |
Beta Was this translation helpful? Give feedback.
Hi,
I have a bunch of apps that do this, and it works flawlessly so I am gonna guess we are missing something here, as usual with cookies, you have to squint hard to see where the error is.
While I setup a reproduction demo, could you please try with setting a path to the cookie? with this value:
/
Edit
Alright, just did some testing, and the
Path
must be set explicitly when using thecookie
library, it is not set to/
by default, which I think is ok, it is just common practice to set it as/
- Do let me know if that change makes it work for you.Here's a video by Feross, from his Web…