mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 16:24:30 +00:00
Fix Resend API key error during build
- Move Resend client instantiation from module level to function - Add validation to skip placeholder API keys - Set empty RESEND_API_KEY and GOOGLE_SERVICE_ACCOUNT_JSON during build
This commit is contained in:
@@ -5,7 +5,13 @@ import { format } from 'date-fns'
|
||||
import { es } from 'date-fns/locale'
|
||||
import { Resend } from 'resend'
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY!)
|
||||
function getResendClient() {
|
||||
const apiKey = process.env.RESEND_API_KEY
|
||||
if (!apiKey || apiKey === 'placeholder' || apiKey === '<REDACTED>') {
|
||||
return null
|
||||
}
|
||||
return new Resend(apiKey)
|
||||
}
|
||||
|
||||
/** @description Send receipt email for booking */
|
||||
export async function POST(
|
||||
@@ -105,6 +111,12 @@ export async function POST(
|
||||
</html>
|
||||
`
|
||||
|
||||
const resend = getResendClient()
|
||||
if (!resend) {
|
||||
console.error('RESEND_API_KEY not configured')
|
||||
return NextResponse.json({ error: 'Email service not configured' }, { status: 500 })
|
||||
}
|
||||
|
||||
const { data: emailResult, error: emailError } = await resend.emails.send({
|
||||
from: 'ANCHOR:23 <noreply@anchor23.mx>',
|
||||
to: booking.customer.email,
|
||||
|
||||
Reference in New Issue
Block a user