Next.js Discord

Discord Forum

Dynamic Server Usage within an API route

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Avatar
Sloth bearOP
Hey!
Getting the following error and not sure what's causing it entirely,

Failed zoom integration DynamicServerError: Dynamic server usage: Page couldn't be rendered statically because it used `headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
    at staticGenerationBailout (/var/task/.next/server/chunks/389.js:88:21)
    at headers (/var/task/.next/server/chunks/2038.js:5676:62)
    at getServerSession (/var/task/.next/server/chunks/3292.js:4272:41)
    at GET (/var/task/.next/server/app/api/integration/zoom/connect/route.js:146:61)
    at /var/task/.next/server/chunks/2038.js:11504:43
    at /var/task/.next/server/chunks/2038.js:12371:36
    at NoopContextManager.with (/var/task/.next/server/chunks/2038.js:6439:30)
    at ContextAPI.with (/var/task/.next/server/chunks/2038.js:6109:58)
    at NoopTracer.startActiveSpan (/var/task/.next/server/chunks/2038.js:7032:34)
    at ProxyTracer.startActiveSpan (/var/task/.next/server/chunks/2038.js:7072:36) {
  digest: 'DYNAMIC_SERVER_USAGE'
}


The source code is the following: https://github.com/exception/jumpcal/blob/811cabdae90b12aa6ecccadaad1886ea280f50d3/src/app/api/integration/zoom/connect/route.ts#L75

4 Replies

Avatar
Sloth bearOP
I assume it may be related to the const session = await getServerSession() call, but not entirely sure, as it's the only thing that could be accessing the headers
Avatar
Great Crested Flycatcher
Same issue here, only at build time
And only when updating to Next.js 15
Avatar
Alfonsus Ardani
Create a new thread and provide more information. This intentional. you can't use dynamic server usage in static routes.