agregado cors para recibir peticiones de otros endpoints distintos

This commit is contained in:
2025-06-11 20:18:41 -06:00
parent ad5bfc788f
commit 2287333965
3 changed files with 16 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
"@google/genai": "^1.4.0",
"@open-wa/wa-automate": "^4.76.0",
"axios": "^1.5.0",
"cors": "^2.8.5",
"dotenv": "^16.5.0",
"express": "^4.18.2",
"ffmpeg-static": "^5.2.0",

View File

@@ -12,6 +12,7 @@
"@google/genai": "^1.4.0",
"@open-wa/wa-automate": "^4.76.0",
"axios": "^1.5.0",
"cors": "^2.8.5",
"dotenv": "^16.5.0",
"express": "^4.18.2",
"ffmpeg-static": "^5.2.0",

View File

@@ -3,6 +3,7 @@ import dotenv from 'dotenv';
import { registerConversationRoutes } from './routes/conversationActions';
import whatsappActionsRouter from './routes/whatsappActions';
import { registerLogSse } from './sse/logSse';
import cors from 'cors';
import {
registerWebhookRoutes,
clearWebhooks,
@@ -38,8 +39,21 @@ if (
}
const app = express();
app.use(cors({
origin: 'http://localhost:5173',
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
credentials: true, // si usás cookies o headers personalizados
}));
app.use(express.json());
registerLogSse(app);
const port = Number(process.env.PORT) || 3001;