Skip to content

fix(auth): disable NextAuth debug mode in production#1748

Open
MinitJain wants to merge 1 commit intoCapSoftware:mainfrom
MinitJain:fix/nextauth-debug-mode-production
Open

fix(auth): disable NextAuth debug mode in production#1748
MinitJain wants to merge 1 commit intoCapSoftware:mainfrom
MinitJain:fix/nextauth-debug-mode-production

Conversation

@MinitJain
Copy link
Copy Markdown
Contributor

@MinitJain MinitJain commented Apr 22, 2026

Summary

  • debug: true was hardcoded unconditionally in authOptions(), causing NextAuth to log full JWT contents, session data, and user objects in production
  • Changed to process.env.NODE_ENV !== "production" so debug logging only activates in development

Security Impact

NextAuth debug mode exposes session tokens and OAuth token data in stdout logs. In any hosted deployment, these logs are retained in log aggregation systems (Vercel, Datadog, CloudWatch, etc.), making every session token readable to anyone with log access.

Test plan

  • Dev environment: verify OTP codes still appear in console (debug active)
  • Production build (NODE_ENV=production): verify no JWT/session data in logs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant