헤더 검색 중앙 정렬·Resend 이메일 OTP·비밀번호 찾기 (v0.0.99)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-12 13:34:21 +09:00
parent 996965740f
commit 6a059a9a59
22 changed files with 984 additions and 34 deletions

View File

@@ -0,0 +1,42 @@
import { createError } from 'h3'
/**
* Resend가 서버 설정으로 사용 가능한지
* @param {{ resendApiKey?: string, resendFromEmail?: string }} config - 런타임 설정
* @returns {boolean}
*/
export const isResendConfigured = (config) => {
const key = String(config?.resendApiKey || '').trim()
const from = String(config?.resendFromEmail || '').trim()
return Boolean(key && from)
}
/**
* Resend REST API로 이메일을 발송한다.
* @param {{ apiKey: string, from: string, to: string, subject: string, html: string }} input - 발송 입력
* @returns {Promise<void>}
*/
export const sendResendEmail = async (input) => {
const res = await fetch('https://api.resend.com/emails', {
method: 'POST',
headers: {
Authorization: `Bearer ${input.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: input.from,
to: [input.to],
subject: input.subject,
html: input.html
})
})
if (!res.ok) {
const detail = await res.text().catch(() => '')
throw createError({
statusCode: 502,
message: '이메일 발송에 실패했습니다. Resend 발신 주소·도메인 설정을 확인해 주세요.',
data: process.env.NODE_ENV === 'development' && detail ? { detail } : undefined
})
}
}