diff --git a/src/index.ts b/src/index.ts index 390b95c..14df1f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,11 +30,23 @@ app.use(helmet()); // }); // app.use('/api', limiter); -// CORS configuration - support multiple origins (comma-separated) -const corsOrigins = process.env.CORS_ORIGIN?.split(',').map(o => o.trim()) || ['http://localhost:5173']; +// CORS configuration - support all localhost ports for development +const allowedOrigins = [ + 'http://localhost:5173', + 'http://localhost:5174', + 'http://localhost:5175', + 'http://localhost:5176', + 'http://localhost:5177', + 'http://localhost:5178', + 'http://localhost:5179', + 'http://localhost:3000', +]; + +const corsOrigin = process.env.CORS_ORIGIN || 'http://localhost:5173'; +const corsOrigins = corsOrigin.split(',').map(o => o.trim()).concat(allowedOrigins); app.use(cors({ - origin: corsOrigins.length > 1 ? corsOrigins : corsOrigins[0], + origin: corsOrigins, credentials: true, }));