Skip to content

Commit 9c0d12a

Browse files
committed
refactor(cors): simplify allowedOrigins by using a separate variable
1 parent 152a6d9 commit 9c0d12a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Back-end/constants/config.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
const allowedOrigins = [
2+
"http://localhost:5173",
3+
"http://localhost:4173",
4+
process.env.CLIENT_URL,
5+
].filter(Boolean);
6+
17
const corsOptions = {
2-
origin: [
3-
"http://localhost:5173",
4-
"http://localhost:4173",
5-
process.env.CLIENT_URL,
6-
],
8+
origin: allowedOrigins,
79
methods: ["GET", "POST", "PUT", "DELETE"],
810
credentials: true,
911
};
1012

1113
const CHATTU_TOKEN = "chattu-token";
1214

13-
export { corsOptions, CHATTU_TOKEN };
15+
export { corsOptions, CHATTU_TOKEN };

0 commit comments

Comments
 (0)