Skip to content

Conversation

@nicknisi
Copy link
Member

@nicknisi nicknisi commented Jan 6, 2026

Summary

  • Makes the headers() call conditional in getAuthorizationUrl() - only called when redirectUri isn't already provided
  • Fixes "headers was called outside request scope" error when running Next.js standalone output with Bun

The headers() function from next/headers is designed for Server Components and Route Handlers, not middleware. When getAuthorizationUrl() is called from middleware context (via updateSession), redirectUri is already passed in, so we can skip the headers() call entirely.

Fixes #288

Make the headers() call conditional in getAuthorizationUrl() to prevent
"headers was called outside request scope" error when running Next.js
standalone output with Bun.

The headers() function from next/headers is designed for Server Components
and Route Handlers, not middleware. When called from middleware context
(via updateSession), redirectUri is already passed in, so we can skip
the headers() call entirely.

Fixes #288
@nicknisi nicknisi merged commit 614a196 into main Jan 6, 2026
5 checks passed
@nicknisi nicknisi deleted the nicknisi/fix-bun-standalone-headers branch January 6, 2026 23:52
@nicknisi nicknisi mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Running standalone bundle using bun yields "headers" error

3 participants