From 011a0127b4390995b522216306721740630a6877 Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 5 Mar 2024 19:20:56 +0600 Subject: [PATCH] env: rename ENABLE_CORS to CORS_WILDCARD for better clarity --- docs/run-an-instance.md | 2 +- src/core/api.js | 4 ++-- src/modules/setup.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/run-an-instance.md b/docs/run-an-instance.md index 99a54f24..2f3d8f56 100644 --- a/docs/run-an-instance.md +++ b/docs/run-an-instance.md @@ -55,7 +55,7 @@ sudo service nscd start | `API_PORT` | `9000` | `9000` | changes port from which api server is accessible. | | `API_URL` | ➖ | `https://co.wuk.sh/` | changes url from which api server is accessible.
***REQUIRED TO RUN API***. | | `API_NAME` | `unknown` | `ams-1` | api server name that is shown in `/api/serverInfo`. | -| `ENABLE_CORS` | `1` | `0` | toggles cross-origin resource sharing.
`0`: disabled. `1`: enabled. | +| `CORS_WILDCARD` | `1` | `0` | toggles cross-origin resource sharing.
`0`: disabled. `1`: enabled. | | `CORS_URL` | not used | `https://cobalt.tools/` | cross-origin resource sharing url. api will be available only from this url. | | `COOKIE_PATH` | not used | `/cookies.json` | path for cookie file relative to main folder. | | `PROCESSING_PRIORITY` | not used | `10` | changes `nice` value* for ffmpeg subprocess. available only on unix systems. | diff --git a/src/core/api.js b/src/core/api.js index 8e26dbd0..de6affe3 100644 --- a/src/core/api.js +++ b/src/core/api.js @@ -14,7 +14,7 @@ import { sha256 } from "../modules/sub/crypto.js"; import { verifyStream } from "../modules/stream/manage.js"; export function runAPI(express, app, gitCommit, gitBranch, __dirname) { - const corsConfig = process.env.ENABLE_CORS === '0' ? { + const corsConfig = process.env.CORS_WILDCARD === '0' ? { origin: process.env.CORS_URL, optionsSuccessStatus: 200 } : {}; @@ -143,7 +143,7 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) { branch: gitBranch, name: process.env.API_NAME || "unknown", url: process.env.API_URL, - cors: process.env?.ENABLE_CORS === "0" ? 0 : 1, + cors_wildcard: process.env?.CORS_WILDCARD === "0" ? 0 : 1, startTime: `${startTimestamp}` }); default: diff --git a/src/modules/setup.js b/src/modules/setup.js index 932cba57..c9eafc45 100644 --- a/src/modules/setup.js +++ b/src/modules/setup.js @@ -59,7 +59,7 @@ function setup() { rl.question(q, apiCors => { let answCors = apiCors.toLowerCase().trim(); - if (answCors !== "y" && answCors !== "yes") ob['ENABLE_CORS'] = '0' + if (answCors !== "y" && answCors !== "yes") ob['CORS_WILDCARD'] = '0' final() }) })