fix(server): catch SMTP errors in auth/request gracefully

Return 200 ok even if email send fails — token is saved in DB and
magic link is logged to console. Prevents 500 on transient SMTP issues.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 03:27:01 +00:00
parent bbebc31624
commit 12522f2478
+4 -1
View File
@@ -75,7 +75,10 @@ function createServer(db) {
const token = crypto.randomBytes(32).toString('hex')
const expiresAt = Date.now() + 24 * 60 * 60 * 1000
db.createMagicToken(token, profile.id, expiresAt)
await sendMagicLink(email, token)
await sendMagicLink(email, token).catch(err => {
// Log SMTP errors but don't fail the request — token is in DB, link logged
console.error('[server] email send failed:', err.message ?? err)
})
return send(res, 200, { ok: true })
}