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:
+4
-1
@@ -75,7 +75,10 @@ function createServer(db) {
|
|||||||
const token = crypto.randomBytes(32).toString('hex')
|
const token = crypto.randomBytes(32).toString('hex')
|
||||||
const expiresAt = Date.now() + 24 * 60 * 60 * 1000
|
const expiresAt = Date.now() + 24 * 60 * 60 * 1000
|
||||||
db.createMagicToken(token, profile.id, expiresAt)
|
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 })
|
return send(res, 200, { ok: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user