binhend 2.1.30 → 2.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo.js +4 -1
- package/package.json +1 -1
- package/src/middleware/cors.js +4 -1
package/demo.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
const { HttpCodes, ConfigLoader, WebBuilder, HttpError, validation } = require('./index');
|
|
3
|
+
const path = require('path');
|
|
3
4
|
|
|
4
5
|
// var jsonPath = __dirname + '/jsconfig.json';
|
|
5
6
|
// var cc = ConfigLoader.json(jsonPath);
|
|
@@ -11,4 +12,6 @@ const loader = new ConfigLoader(config);
|
|
|
11
12
|
|
|
12
13
|
loader.object({ foo: '1', koo: '2', hoo: '3' }, { filter: ['koo', 'hoo'] });
|
|
13
14
|
|
|
14
|
-
console.log('config', config);
|
|
15
|
+
console.log('config', config);
|
|
16
|
+
|
|
17
|
+
console.log(path.resolve(__dirname, './app.secret'));
|
package/package.json
CHANGED
package/src/middleware/cors.js
CHANGED
|
@@ -34,7 +34,10 @@ module.exports = (options) => {
|
|
|
34
34
|
if (origin === undefined) return next();
|
|
35
35
|
|
|
36
36
|
// Verify allowed origins
|
|
37
|
-
const
|
|
37
|
+
const acceptLocalhost = allowedOrigins.includes('localhost') && /^https{0,1}:\/\/localhost:\d+$/.test(origin);
|
|
38
|
+
const acceptOrigin = acceptLocalhost || allowedOrigins.length === 0 || allowedOrigins.includes(origin);
|
|
39
|
+
const allowedOrigin = acceptOrigin ? origin : '';
|
|
40
|
+
|
|
38
41
|
res.header('Access-Control-Allow-Origin', allowedOrigin);
|
|
39
42
|
|
|
40
43
|
if (!allowedOrigin) {
|