fix(cors): permitir *.vercel.app nas edge functions#39
Conversation
Catalog and other edge-function-backed features returned no data on Vercel preview deploys (e.g. we-dream-big-git-main-juca1.vercel.app) because the shared CORS allowlist only covered lovable.app, lovableproject.com, atomicabr.com.br and localhost. Browsers blocked the preflight before any request reached the function — visible in logs as cors_preflight_warn with origin_allowed: false. Production (promogifts.com.br) is unaffected since it is in the exact allowlist already. Requires edge functions to be redeployed for the change to take effect. https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdicionado padrão regex para permitir requisições com ChangesValidação CORS para Vercel
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Updates to Preview Branch (claude/cors-allow-vercel) ↗︎
Tasks are run on every commit but only new migration files are pushed.
❌ Branch Error • Thu, 21 May 2026 18:27:04 UTC View logs for this Workflow Run ↗︎. |
Problema
Catálogo aparece vazio (0 itens) quando o app é acessado pela URL de preview do Vercel (
we-dream-big-git-*.vercel.app). Tudo funciona empromogifts.com.br.Causa identificada nos logs da edge function
external-db-bridge:O allowlist em
supabase/functions/_shared/cors.tscobrelovable.app,lovableproject.com,atomicabr.com.brelocalhost, mas não Vercel. Resultado: o navegador bloqueia o preflight antes de qualquer chamada chegar à função.Fix
Adiciona um pattern para
*.vercel.appemALLOWED_ORIGIN_PATTERNS:/^https:\/\/[a-z0-9-]+\.atomicabr\.com\.br$/i, + /^https:\/\/[a-z0-9-]+\.vercel\.app$/i, /^http:\/\/localhost(?::\d+)?$/i,Produção (
promogifts.com.br) não é afetada — já estava na lista exata.As edge functions precisam ser re-deployadas para o novo
cors.tschegar em runtime. O workflowDeploy Edge Functionsfaz isso automaticamente em push paramainque tocasupabase/functions/**, mas depende do secretSUPABASE_ACCESS_TOKENestar configurado em GitHub Actions. Se ainda não estiver, o deploy do CI vai falhar — nesse caso, fazer deploy manual via Supabase CLI ou configurar o token.https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7
Generated by Claude Code
Summary by cubic
Allow
*.vercel.appin edge function CORS to fix blocked requests on Vercel preview deployments. This restores the catalog and other edge-function-backed features on preview sites; production remains unchanged.Bug Fixes
*.vercel.appregex toALLOWED_ORIGIN_PATTERNSinsupabase/functions/_shared/cors.ts.Migration
mainifSUPABASE_ACCESS_TOKENis set; otherwise deploy via the Supabase CLI.Written for commit 6cd37ef. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Release Notes
*.vercel.appagora são aceitas pelo mecanismo de validação de origens do backend. Isso permite que aplicações hospedadas nesta plataforma possam fazer requisições para os serviços sem problemas de CORS, aumentando significativamente a compatibilidade e flexibilidade nas integrações com aplicações terceirizadas.