feat: add comprehensive auth debugging logs#129
Merged
Conversation
Add detailed logging for cross-domain authentication debugging: Frontend: - Log auth client configuration (baseURL, environment) - Log login flow steps (type detection, result, navigation) - Log session fetch in root beforeLoad - Log navigation steps after auth (session state, cookies, router) Backend: - Log Better Auth configuration (cookie domain, CORS origins) - Log CORS middleware configuration - Log incoming auth requests (method, path, origin) - Log Set-Cookie headers in auth responses This will help diagnose staging login redirect issues where frontend and API are on different subdomains. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes authentication on staging where frontend (staging.tuvix.app) and API (tuvix-api-staging.cf-93e.workers.dev) are on different domains. Changes: - Client: Add credentials: 'include' to Better Auth client for cross-origin cookies - Server: Set sameSite=none, secure=true, partitioned=true for cross-domain auth - Secrets: Remove COOKIE_DOMAIN from staging (only for subdomains, not cross-domain) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Staging uses subdomains (staging.tuvix.app and api-staging.tuvix.app), not completely different domains. Requires cross-subdomain cookies. Changes: - Reverted cross-origin cookie attributes (sameSite=none, etc.) - Set COOKIE_DOMAIN=.tuvix.app for subdomain cookie sharing - Keep credentials: 'include' on client (needed for CORS with credentials) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add detailed logging for cross-domain authentication debugging to help diagnose staging login redirect issues.
Changes
Frontend Logging
Backend Logging
Why This Helps
When testing on staging, you'll see in the browser console:
And in Cloudflare Workers logs:
This will immediately show if:
Testing
Deploy to staging and check:
[Auth]and[Root]logs🔧and[Auth]logs