@azteam/express 1.2.379 → 1.2.380
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/lib/Server.js +1 -8
- package/package.json +1 -1
- package/src/Server.js +1 -8
package/lib/Server.js
CHANGED
|
@@ -52,7 +52,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
52
52
|
_classCallCheck(this, Server);
|
|
53
53
|
this.options = _objectSpread({
|
|
54
54
|
redis: null,
|
|
55
|
-
isAllowEmptyOrigin: true,
|
|
56
55
|
whiteList: null,
|
|
57
56
|
cookieOption: {},
|
|
58
57
|
debug: process.env.NODE_ENV === 'development',
|
|
@@ -60,7 +59,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
60
59
|
}, options);
|
|
61
60
|
this.systemUser = this.options.systemUser;
|
|
62
61
|
this.redis = this.options.redis;
|
|
63
|
-
this.isAllowEmptyOrigin = this.options.isAllowEmptyOrigin;
|
|
64
62
|
this.whiteList = this.options.whiteList;
|
|
65
63
|
this.debug = this.options.debug;
|
|
66
64
|
this.cookieOption = _objectSpread({
|
|
@@ -115,7 +113,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
115
113
|
if (!_lodash["default"].isEmpty(this.controllers)) {
|
|
116
114
|
var WHITE_LIST = this.whiteList,
|
|
117
115
|
COOKIE_OPTION = this.cookieOption,
|
|
118
|
-
IS_ALLOW_EMPTY = this.isAllowEmptyOrigin,
|
|
119
116
|
SYSTEM_USER = this.systemUser,
|
|
120
117
|
app = (0, _express["default"])();
|
|
121
118
|
app.use((0, _helmet["default"])({
|
|
@@ -137,11 +134,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
137
134
|
agent = req.header('User-Agent');
|
|
138
135
|
var error = null;
|
|
139
136
|
if (!authorization && !agent.startsWith(SYSTEM_USER)) {
|
|
140
|
-
if (!
|
|
141
|
-
if (!IS_ALLOW_EMPTY) {
|
|
142
|
-
error = new _error.ErrorException(_error.CORS, "Not allowed by CORS");
|
|
143
|
-
}
|
|
144
|
-
} else if (WHITE_LIST && !WHITE_LIST.some(function (re) {
|
|
137
|
+
if (origin && WHITE_LIST && !WHITE_LIST.some(function (re) {
|
|
145
138
|
return origin.endsWith(re);
|
|
146
139
|
})) {
|
|
147
140
|
error = new _error.ErrorException(_error.CORS, "".concat(origin, " Not allowed by CORS"));
|
package/package.json
CHANGED
package/src/Server.js
CHANGED
|
@@ -25,7 +25,6 @@ class Server {
|
|
|
25
25
|
constructor(serviceDirs, options = {}, errorCallback = null) {
|
|
26
26
|
this.options = {
|
|
27
27
|
redis: null,
|
|
28
|
-
isAllowEmptyOrigin: true,
|
|
29
28
|
whiteList: null,
|
|
30
29
|
cookieOption: {},
|
|
31
30
|
debug: process.env.NODE_ENV === 'development',
|
|
@@ -36,7 +35,6 @@ class Server {
|
|
|
36
35
|
this.systemUser = this.options.systemUser;
|
|
37
36
|
|
|
38
37
|
this.redis = this.options.redis;
|
|
39
|
-
this.isAllowEmptyOrigin = this.options.isAllowEmptyOrigin;
|
|
40
38
|
this.whiteList = this.options.whiteList;
|
|
41
39
|
this.debug = this.options.debug;
|
|
42
40
|
|
|
@@ -94,7 +92,6 @@ class Server {
|
|
|
94
92
|
if (!_.isEmpty(this.controllers)) {
|
|
95
93
|
const WHITE_LIST = this.whiteList,
|
|
96
94
|
COOKIE_OPTION = this.cookieOption,
|
|
97
|
-
IS_ALLOW_EMPTY = this.isAllowEmptyOrigin,
|
|
98
95
|
SYSTEM_USER = this.systemUser,
|
|
99
96
|
app = express();
|
|
100
97
|
|
|
@@ -120,11 +117,7 @@ class Server {
|
|
|
120
117
|
|
|
121
118
|
let error = null;
|
|
122
119
|
if (!authorization && !agent.startsWith(SYSTEM_USER)) {
|
|
123
|
-
if (!origin) {
|
|
124
|
-
if (!IS_ALLOW_EMPTY) {
|
|
125
|
-
error = new ErrorException(CORS, `Not allowed by CORS`);
|
|
126
|
-
}
|
|
127
|
-
} else if (WHITE_LIST && !WHITE_LIST.some((re) => origin.endsWith(re))) {
|
|
120
|
+
if (origin && WHITE_LIST && !WHITE_LIST.some((re) => origin.endsWith(re))) {
|
|
128
121
|
error = new ErrorException(CORS, `${origin} Not allowed by CORS`);
|
|
129
122
|
}
|
|
130
123
|
}
|