Skip to content

Commit 312d699

Browse files
fix: harden ALLOWED_ORIGINS parsing to avoid lockout on empty values
1 parent 4e62471 commit 312d699

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

backend/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const app = express();
1515

1616
// CORS configuration — allowed origins are read from the ALLOWED_ORIGINS env var
1717
// (comma-separated). Falls back to localhost for local development.
18-
const allowedOrigins = process.env.ALLOWED_ORIGINS
19-
? process.env.ALLOWED_ORIGINS.split(',').map(origin => origin.trim())
20-
: ['http://localhost:5173'];
18+
const parsedOrigins = process.env.ALLOWED_ORIGINS
19+
? process.env.ALLOWED_ORIGINS.split(',').map(origin => origin.trim()).filter(Boolean)
20+
: [];
21+
const allowedOrigins = parsedOrigins.length > 0 ? parsedOrigins : ['http://localhost:5173'];
2122

2223
app.use(cors({
2324
origin: function (origin, callback) {

0 commit comments

Comments
 (0)