@azteam/express 1.2.250 → 1.2.252
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/package.json +1 -1
- package/src/Server.js +15 -15
package/package.json
CHANGED
package/src/Server.js
CHANGED
|
@@ -150,24 +150,24 @@ class Server {
|
|
|
150
150
|
|
|
151
151
|
app.use(
|
|
152
152
|
cors(function (req, callback) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!
|
|
160
|
-
if (!
|
|
161
|
-
|
|
162
|
-
error = new ErrorException(CORS, `Not allowed by CORS`);
|
|
163
|
-
}
|
|
164
|
-
} else if (!WHITE_LIST.some((re) => origin.endsWith(re))) {
|
|
165
|
-
error = new ErrorException(CORS, `${origin} Not allowed by CORS`);
|
|
153
|
+
const origin = req.header('Origin');
|
|
154
|
+
const authorization = req.header('Authorization');
|
|
155
|
+
|
|
156
|
+
let error = null;
|
|
157
|
+
|
|
158
|
+
if (!authorization) {
|
|
159
|
+
if (!origin) {
|
|
160
|
+
if (!isAllowEmptyOrigin) {
|
|
161
|
+
error = new ErrorException(CORS, `Not allowed by CORS`);
|
|
166
162
|
}
|
|
163
|
+
} else if (!WHITE_LIST.some((re) => origin.endsWith(re))) {
|
|
164
|
+
error = new ErrorException(CORS, `${origin} Not allowed by CORS`);
|
|
167
165
|
}
|
|
168
|
-
|
|
169
|
-
callback(error, true);
|
|
170
166
|
}
|
|
167
|
+
callback(error, {
|
|
168
|
+
credentials: true,
|
|
169
|
+
origin: true,
|
|
170
|
+
});
|
|
171
171
|
})
|
|
172
172
|
);
|
|
173
173
|
|