diff --git a/index.js b/index.js index 48f9da4..fb3d5cf 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,16 @@ import { startup } from './src/utils/startup.js'; import { fileURLToPath } from 'url'; const PORT = process.env.PORT; -const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(',') || []; // localhost is also allowed. (from any localhost port) +const parseAllowedOrigins = (allowedOrigins) => { + if (!allowedOrigins) return []; + const stripped = allowedOrigins.trim().replace(/^\[|\]$/g, ''); + return stripped + .split(',') + .map((s) => s.trim().replace(/^\"|\"$|^\'|\'$/g, '')) + .filter(Boolean); +}; +// localhost is also allowed. (from any localhost port) +const allowedOrigins = parseAllowedOrigins(process.env.ALLOWED_ORIGINS) || []; const app = express(); app.use( diff --git a/package-lock.json b/package-lock.json index e7b7047..2672ed1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "express": "^5.1.0", "node-cache": "^5.1.2", "node-fetch": "^3.3.2", - "prettier": "^3.6.2", + "prettier": "^3.7.3", "unpacker": "^1.0.1", "wyzie-lib": "^2.2.5" } @@ -1872,10 +1872,9 @@ "license": "MIT" }, "node_modules/prettier": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", - "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", - "license": "MIT", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.3.tgz", + "integrity": "sha512-QgODejq9K3OzoBbuyobZlUhznP5SKwPqp+6Q6xw6o8gnhr4O85L2U915iM2IDcfF2NPXVaM9zlo9tdwipnYwzg==", "bin": { "prettier": "bin/prettier.cjs" }, diff --git a/package.json b/package.json index bd5bd38..4bfc1b0 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "express": "^5.1.0", "node-cache": "^5.1.2", "node-fetch": "^3.3.2", - "prettier": "^3.6.2", + "prettier": "^3.7.3", "unpacker": "^1.0.1", "wyzie-lib": "^2.2.5" },