diff --git a/core/package-lock.json b/core/package-lock.json index 7145cd2..d8b0e68 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "soul-cli", - "version": "0.2.2", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "soul-cli", - "version": "0.2.2", + "version": "0.3.0", "license": "MIT", "dependencies": { "better-sqlite3": "^8.1.0", diff --git a/core/package.json b/core/package.json index fe1409c..fa53946 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "soul-cli", - "version": "0.2.2", + "version": "0.3.0", "description": "A SQLite REST and Realtime server", "main": "src/server.js", "bin": { diff --git a/core/src/config/index.js b/core/src/config/index.js index 1eb4d17..6b94b92 100644 --- a/core/src/config/index.js +++ b/core/src/config/index.js @@ -75,7 +75,8 @@ module.exports = { filename: argv.database || envVars.DB || ':memory:', }, cors: { - origin: argv.cors.split(',') || envVars.CORS_ORIGIN_WHITELIST.split(','), + origin: argv.cors?.split(',') || + envVars.CORS_ORIGIN_WHITELIST?.split(',') || ['*'], }, rateLimit: { enabled: argv['rate-limit-enabled'] || envVars.RATE_LIMIT_ENABLED, diff --git a/core/src/index.js b/core/src/index.js index 04ea0aa..cfb22d6 100755 --- a/core/src/index.js +++ b/core/src/index.js @@ -28,13 +28,19 @@ app.use(bodyParser.json()); db.pragma('journal_mode = WAL'); // Enable CORS +let corsOrigin = config.cors.origin; + +if (corsOrigin.includes('*')) { + corsOrigin = '*'; +} + const corsOptions = { - origin: config.cors.origin, + origin: corsOrigin, }; + app.use(cors(corsOptions)); // Log requests - if (config.verbose !== null) { app.use( expressWinston.logger({