diff --git a/config.js b/config.js index 13bb3eb..183c90c 100755 --- a/config.js +++ b/config.js @@ -2,7 +2,13 @@ module.exports = { ports: { mainServerPort: 3005, }, - address: 'b.hippoz.xyz', + address: 'localhost', + //restrictions: { + // signup: { + // specialCode: '' + // } + //}, + corsAllowList: [ 'localhost' ], mongoUrl: 'mongodb://192.168.0.105:27017/app', bcryptRounds: 10, roleMap: { diff --git a/index.js b/index.js index 4424e56..f3680ba 100755 --- a/index.js +++ b/index.js @@ -18,7 +18,13 @@ app.use(express.urlencoded({ extended: false })); app.use(express.json()); app.use(cookieParser()); app.use(cors({ - origin: config.isHttps ? `https://${config.address}` : `http://${config.address}`, + origin: function (origin, callback) { + if (config.corsAllowList.indexOf(origin) !== -1) { + callback(null, true); + } else { + callback(new Error('Not allowed by CORS')); + } + }, credentials: true, optionsSuccessStatus: 200 }));