Next.js Discord

Discord Forum

Error: "Can't be rendered statically because it used 'headers'

Unanswered
English Lop posted this in #help-forum
Open in Discord
English LopOP
Getting this error in the terminal when I build the code: Error in /api/users: n [Error]: Dynamic server usage: Route /api/users couldn't be rendered statically because it used `headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

Is this a real error... if not can I remove this warning?

5 Replies

English LopOP
@Anay-208 | Ping in replies thanks for your reply, do I need to update my nextjs config
@English Lop <@755810867878297610> thanks for your reply, do I need to update my nextjs config
If you’re not using static built, you can remove related fields from config like output
English LopOP
@Anay-208 | Ping in replies How to change to dynamic just for those files?
@English Lop <@755810867878297610> How to change to dynamic just for those files?
If you are using static build, you can’t set a specific file to be dynamic