Next.js Discord

Discord Forum

Get cookies in `/lib`

Answered
Xander posted this in #help-forum
Open in Discord
I have a /lib/api/fetch.ts class that is responsible for fetching external api requests.
How can I get my auth cookie from within here?
Answered by Xander
adding an explicit use server to it worked
View full answer

10 Replies

this is intended to be called server side
but of course i get this
do you import this file in any client components?
@joulev do you import this file in any client components?
well components are client only if you put 'use client' right?
in that case no
only one component, and a server action
that's weird...
could you make a minimal reproduction repository?
adding an explicit use server to it worked
Answer
i dont have time for reproductions its a commissioned project with a deadline sorry :/