You're importing a component that needs next/headers. That only works in a Server Component which...
Unanswered
Black-tailed Gnatcatcher posted this in #help-forum
Black-tailed GnatcatcherOP
Context:
Using nextjs app router + NestJS backend and want to fetch to my server components WITHOUT using route handlers because I realised they are useless for that use case.
Problem:
I need my fetch calls to have two specific headers
Using nextjs app router + NestJS backend and want to fetch to my server components WITHOUT using route handlers because I realised they are useless for that use case.
Problem:
I need my fetch calls to have two specific headers
"x-real-ip" & "x-forwarded-for", to handle my rate limiting. However as title says I get an error due to using headers outside of APP router. Please see example for example in code, my problem is I want to fetch in a different file than my server components to make my code easier to read as fetches get more.1 Reply
@Black-tailed Gnatcatcher **__Context__**:
Using nextjs app router + NestJS backend and want to fetch to my server components WITHOUT using route handlers because I realised they are useless for that use case.
**__Problem__**:
I need my fetch calls to have two specific headers `"x-real-ip"` & `"x-forwarded-for"`, to handle my rate limiting. However as title says I get an error due to using headers outside of APP router. Please see example for example in code, my problem is I want to fetch in a different file than my server components to make my code easier to read as fetches get more.
in the same file that you import
next/headers, do you export anything that is eventually imported to a client component or something similar?