Fix magic link submission getting stuck in production#31
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces server-side magic-link email authentication. A new API route handles rate limiting, email validation, and Supabase OTP dispatch. The frontend auth service is updated to call this route via fetch instead of directly invoking Supabase, adding timeout protection and defensive response parsing. ChangesMagic-Link Email Authentication
Sequence DiagramsequenceDiagram
participant Browser as Browser / signInWithOtp
participant Endpoint as POST /api/auth/magic-link
participant RateLimit as Rate Limiter
participant Validator as Email Validator
participant Supabase as Supabase Auth
Browser->>Endpoint: fetch POST with email
Endpoint->>RateLimit: check loginRateLimit
alt Rate Limited
RateLimit-->>Endpoint: return lock state
Endpoint-->>Browser: 429 error
else Allowed
RateLimit-->>Endpoint: proceed
Endpoint->>Validator: normalize & validate email
alt Invalid Email
Validator-->>Endpoint: validation failed
Endpoint-->>Browser: 400 error
else Valid Email
Validator-->>Endpoint: email valid
Endpoint->>Supabase: signInWithOtp with emailRedirectTo
Supabase-->>Endpoint: success or error response
alt OTP Success
Endpoint-->>Browser: 200 with check email message
else OTP Error
Endpoint-->>Browser: 400 with error message
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes the login/signup magic link flow getting stuck at
Sending...in production.Changes
/api/auth/magic-linkserver route for Supabase OTP requestsVerification
npm.cmd exec eslint app/api/auth/magic-link/route.ts lib/features/auth/auth-service.ts app/login/page.tsx app/signup/page.tsxnpm.cmd run buildSummary by CodeRabbit