Next.js Discord

Discord Forum

Data Fetching with auth headers

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
Hi,

I am facing an issue.
Next.js docs say that we can fetch data wherever we want.

I am fetching data in nested server components and that data fetching need acess to cookies fn (dynamic fn).

But when I call cookies fn in an authAPIHelper, next js gives me error at build time.

- When I explicitly call the cookies() fn as shown in the screenshot then the error goes away.

Why?


Similar issue is with API routes

- Dynamic Server usage: Route /api/rules couldn't be rendered stayically because it used cookies.

Why would I want to render my API route statically?

########
Please Help

1 Reply

Siamese
bro aint got screenshots