I've completed a guide and now aim to retrieve user details using a server component. However, despite the cookie being present in the browser, it doesn't seem to appear in the request.
I customized my profile page and transformed it into a server component. However, upon reloading the page to initiate the fetch request, the token cookie is absent. I've verified this using the following lines of code within the route handler:
const token = request.cookies.get("token")?.value || "";
console.log(token, "token");
If you are using NextJS, it is best to use the cookies-next library https://www.npmjs.com/package/cookies-next
Try this:
For fetch request,
Without using a library: