-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfig.js
33 lines (29 loc) · 924 Bytes
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const config = {
development: {
port: 3000,
host: "localhost",
corsOrigin: "http://localhost:5173",
},
production: {
port: process.env.PORT || 3000,
host: "0.0.0.0",
corsOrigin: [
"https://steadfastapp.in",
"https://www.steadfastapp.in",
"https://api.steadfastapp.in",
],
},
};
const environment = process.env.NODE_ENV || "development";
const currentConfig = config[environment];
// Ensure corsOrigin is always an array
currentConfig.corsOrigin = Array.isArray(currentConfig.corsOrigin)
? currentConfig.corsOrigin
: [currentConfig.corsOrigin];
// Add 'Access-Control-Allow-Origin' header to the response
currentConfig.corsHeaders = {
"Access-Control-Allow-Origin": currentConfig.corsOrigin,
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
};
module.exports = currentConfig;