Skip to content

Commit

Permalink
Add support for multiple origins in CORS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mipronimo committed Sep 29, 2024
1 parent d88bb02 commit 7ca20a0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ async function initSequelize() {
}
}

let origin = process.env.ORIGIN_URL || "";
if (origin) {
try {
origin = JSON.parse(origin);
} catch (e) {
origin = [origin];
}
} else {
origin = [];
}
origin.push(process.env.LAMA_APP_URL || "http://localhost:9000");
var corsOptions = {
origin: process.env.LAMA_APP_URL || "http://localhost:9000"
origin: origin,
};

app.use(cors(corsOptions));
Expand Down

0 comments on commit 7ca20a0

Please sign in to comment.