Skip to content

Conversation

@Iweisc
Copy link

@Iweisc Iweisc commented Dec 28, 2025

This adds a fallback mechanism for scenarios where the x-workos-middleware header doesn't propagate correctly to API routes (e.g., when using custom middleware wrappers in Next.js 16 with proxy.ts).

When WORKOS_SKIP_MIDDLEWARE_CHECK=true is set, the getSessionFromHeader() function will fall back to reading the session directly from cookies instead of throwing an error about missing middleware coverage.

Fixes #351

…eader check

This adds a fallback mechanism for scenarios where the x-workos-middleware header
doesn't propagate correctly to API routes (e.g., when using custom middleware
wrappers in Next.js 16 with proxy.ts).

When WORKOS_SKIP_MIDDLEWARE_CHECK=true is set, the getSessionFromHeader() function
will fall back to reading the session directly from cookies instead of throwing
an error about missing middleware coverage.

Fixes workos#351
@nicknisi
Copy link
Member

nicknisi commented Jan 6, 2026

As mentioned in #351 bypassing middleware can cause issues. Closing this in favor of the recommended solution in that issue. Thanks!

@nicknisi nicknisi closed this Jan 6, 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.

withAuth Errors Out Claiming Route Not Covered by Middleware Despite Matcher Including It

2 participants