diff --git a/backend/package.json b/backend/package.json index 973101e0..2931481b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -23,7 +23,7 @@ "scripts": { "build": "tsc", "start": "node dist/src/server.js", - "dev:start": "cross-env USE_HTTPS=false TESTING_MODE=ENABLED nodemon -I --exec node --experimental-specifier-resolution=node --loader ts-node/esm ./src/server.ts", + "dev:start": "cross-env USE_HTTPS=false SERVER_CORS_ORIGIN=* nodemon -I --exec node --experimental-specifier-resolution=node --loader ts-node/esm ./src/server.ts", "lint": "eslint src --fix", "format": "prettier --ignore-path .gitignore --write '**/*.{ts,js,json,md}'", "pack": "npm pack" diff --git a/backend/src/config.ts b/backend/src/config.ts index 5d93bb67..a57c570a 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -1,14 +1,14 @@ - import dotenv from 'dotenv'; if (process.env.CALL_CONFIG_DIR) { - dotenv.config({ path: process.env.CALL_CONFIG_DIR }); + dotenv.config({ path: process.env.CALL_CONFIG_DIR }); } else { - dotenv.config(); + dotenv.config(); } // General server configuration export const SERVER_PORT = process.env.SERVER_PORT || 6080; +export const SERVER_CORS_ORIGIN = process.env.SERVER_CORS_ORIGIN || '*'; export const CALL_NAME_ID = process.env.CALL_NAME_ID || 'OpenViduCall'; export const CALL_PRIVATE_ACCESS = process.env.CALL_PRIVATE_ACCESS || 'false'; export const CALL_USER = process.env.CALL_USER || 'user'; diff --git a/backend/src/server.ts b/backend/src/server.ts index db4bb990..a8ecfda6 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -21,16 +21,17 @@ import { CALL_ADMIN_USER, CALL_AWS_REGION, CALL_LOG_LEVEL, - CALL_NAME_ID + CALL_NAME_ID, + SERVER_CORS_ORIGIN } from './config.js'; const createApp = () => { const app = express(); // Enable CORS support - if (process.env.TESTING_MODE === 'ENABLED') { - console.log('CORS enabled'); - app.use(cors({ origin: '*' })); + if (SERVER_CORS_ORIGIN) { + console.log('CORS Origin:', SERVER_CORS_ORIGIN); + app.use(cors({ origin: SERVER_CORS_ORIGIN })); } const __filename = fileURLToPath(import.meta.url);