Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-23 21:32:32 +00:00
co-authored by renee-png
parent bdcb8a4d80
commit b6c5a8b4c1
@@ -53,10 +53,12 @@ export const Route = createFileRoute("/lovable/email/transactional/send")({
const token = authHeader.slice('Bearer '.length).trim()
const supabase = createClient(supabaseUrl, supabaseServiceKey)
const { data: { user }, error: authError } = await supabase.auth.getUser(token)
if (authError || !user) {
return Response.json({ error: 'Unauthorized' }, { status: 401 })
// Allow service-role key for server-to-server calls (cron, internal).
if (token !== supabaseServiceKey) {
const { data: { user }, error: authError } = await supabase.auth.getUser(token)
if (authError || !user) {
return Response.json({ error: 'Unauthorized' }, { status: 401 })
}
}
// Parse request body