propro-utils 1.4.84 → 1.4.85
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/index.js +12 -5
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -315,22 +315,29 @@ class AuthMiddleware {
|
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
proxyToAuthServer = async (req, path) => {
|
|
318
|
+
let accessToken = null;
|
|
318
319
|
if (this.pathRequiresAccessToken(path)) {
|
|
319
|
-
|
|
320
|
+
console.log('path requires access token');
|
|
321
|
+
accessToken = req.cookies['x-access-token'];
|
|
320
322
|
if (!accessToken) {
|
|
321
323
|
throw new Error('No access token provided');
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
326
|
|
|
327
|
+
let headers = {
|
|
328
|
+
'Content-Type': 'application/json',
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
if (accessToken) {
|
|
332
|
+
headers.Authorization = `Bearer ${accessToken}`;
|
|
333
|
+
}
|
|
334
|
+
|
|
325
335
|
const formattedAuthUrl = formatRedirectUrl(this.options.authUrl);
|
|
326
336
|
return axios({
|
|
327
337
|
method: req.method,
|
|
328
338
|
url: `${formattedAuthUrl}${path}`,
|
|
329
339
|
data: req.body,
|
|
330
|
-
headers:
|
|
331
|
-
Authorization: `Bearer ${accessToken}`,
|
|
332
|
-
'Content-Type': 'application/json',
|
|
333
|
-
},
|
|
340
|
+
headers: headers,
|
|
334
341
|
});
|
|
335
342
|
};
|
|
336
343
|
|