Next.js Discord

Discord Forum

Dynamic Server Usage within an API route

Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
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:
    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) {

The source code is the following:

4 Replies

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
Great Crested Flycatcher
Same issue here, only at build time
And only when updating to Next.js 15
Alfonsus Ardani
Create a new thread and provide more information. This intentional. you can't use dynamic server usage in static routes.