Add cors stuff

This commit is contained in:
Joey Yakimowich-Payne 2026-01-14 19:44:13 -07:00
commit 9363f643f0
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
10 changed files with 116 additions and 49 deletions

View file

@ -9,8 +9,9 @@ import gamesRouter from './routes/games.js';
const app = express();
const PORT = process.env.PORT || 3001;
const corsOrigins = (process.env.CORS_ORIGIN || 'http://localhost:5173').split(',').map(o => o.trim());
app.use(cors({
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
origin: corsOrigins.length === 1 ? corsOrigins[0] : corsOrigins,
credentials: true,
}));