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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.4.84",
3
+ "version": "1.4.85",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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
- const accessToken = req.cookies['x-access-token'];
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