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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "2.1.30",
3
+ "version": "2.1.31",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",
@@ -34,7 +34,10 @@ module.exports = (options) => {
34
34
  if (origin === undefined) return next();
35
35
 
36
36
  // Verify allowed origins
37
- const allowedOrigin = allowedOrigins.length === 0 || allowedOrigins.includes(origin) ? origin : '';
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) {