Everywhere ctx.session.user in a router is used I get this error

all these three things and probably more return that same error:
[ Server ] Error: Route "/dashboard" used `...headers()` or similar iteration. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Call Stack
Next.js
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
getUserLocale
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
[ Server ] Error: Route "/dashboard" used `...headers()` or similar iteration. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Call Stack
Next.js
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
getUserLocale
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
<anonymous>
file://http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js (3700:31)
No description
No description
No description
4 Replies
Yiannis
Yiannis4w ago
Can you share your trpc file (where the context gets defined and also the “server” api file
Jeremy
JeremyOP4w ago
this was a next-auth issue.
CommandoBrando
@Jeremy were you able to resolve it? What is the fix. Just upgraded to nextjs15 and I am getting this now
Jeremy
JeremyOP4w ago
So first of all update your next auth to the latest version If that doesnt do the job then somewhere in server.ts modify the create context like so:
import { headers } from "next/headers"; // probably already imported

const createContext = cache(async () => {
const heads = new Headers(await headers());
import { headers } from "next/headers"; // probably already imported

const createContext = cache(async () => {
const heads = new Headers(await headers());
Want results from more Discord servers?
Add your server