diff --git a/whatsapp-router/src/index.ts b/whatsapp-router/src/index.ts index cceb2c9..cc67b2e 100644 --- a/whatsapp-router/src/index.ts +++ b/whatsapp-router/src/index.ts @@ -44,12 +44,19 @@ const app = express(); app.use(cors({ - origin: 'http://localhost:5173', + origin: (origin, callback) => { + if (!origin || origin === 'http://localhost:5173' || /\.interno\.com$/.test(origin)) { + callback(null, true); + } else { + callback(new Error('No permitido por CORS')); + } + }, methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], - credentials: true, // si usás cookies o headers personalizados + credentials: true, })); + app.use(express.json());