Next.js Discord

Discord Forum

Error: Route "/" used `headers().get('x-forwarded-proto')`

Unanswered
Gazami crab posted this in #help-forum
Open in Discord
Avatar
Gazami crabOP
[ Server ]  Error: Route "/" used `headers().get('x-forwarded-proto')`. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis


Who had similar issues?

it happens when auth() is called on RootLayout

const session = await auth();

4 Replies

Avatar
Silver Fox
I have a similar issue with a library that depends on synchronous headers(), and since headers() are async in v15 it breaks with same error:
Error: Route "/" used headers().get('x-forwarded-proto')
Avatar
Gazami crabOP
i am using Authjs v5
tried to update, and now it breaks everything. I think need to wait the fixes from auth js maintainers
Avatar
Silver Fox
question for mainainers:
can we force pages to wait for the request data as in v14 if we need it?
In my case, I use headers() in translations, and with the new "async request APIs" updates, I can't make it work properly.