Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ const originValidationMiddleware = (

// Default origins based on CLIENT_PORT or use environment variable
const clientPort = process.env.CLIENT_PORT || "6274";
const defaultOrigin = `http://localhost:${clientPort}`;
const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(",") || [
defaultOrigin,
];
const defaultOrigins = [`http://localhost:${clientPort}`];
if (clientPort === "80") {
defaultOrigins.push("http://localhost");
}
const allowedOrigins =
process.env.ALLOWED_ORIGINS?.split(",") || defaultOrigins;

if (origin && !allowedOrigins.includes(origin)) {
console.error(`Invalid origin: ${origin}`);
Expand Down