#How to access cookie in my server If I am not using Nextjs API routes for backend

4 messages · Page 1 of 1 (latest)

woven patio
#

I have using Next.js for client and node and express application for backend.
I am not using nextjs api routes for backend.

frontend on port 3000, backend 3001

I want to access the cookies in my node application, which shows undefined at the moment.

  • I am sure the cookies are present as it is visible in the devtools
  • Probably not a cors issue

I am able to access the cookie in nextjs in getServerSideProps and pass the cookie in headers.

  const res = await fetch(url,
    {
      headers: {
        Cookie: context.req.cookies.session,
      },
    }
  );

Suppose I have a mutation for creating a post, How do I pass the cookie to my backend(I cant use getServersideprops for that).

rugged root
#

Cookie a forbidden header

woven patio