From 6bebbfe9f334a773133348267dbfe5ee6e934f85 Mon Sep 17 00:00:00 2001 From: lohxt1 Date: Wed, 30 Oct 2024 16:35:52 +0530 Subject: [PATCH] fix: include global env varaibles for oauth2 --- .../src/providers/ReduxStore/slices/collections/actions.js | 2 +- packages/bruno-electron/src/ipc/network/index.js | 2 +- .../src/ipc/network/prepare-collection-request.js | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 066889d68..75c6f2cb9 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -201,7 +201,7 @@ export const sendCollectionOauth2Request = (collectionUid, itemUid) => (dispatch const environment = findEnvironmentInCollection(collectionCopy, collection.activeEnvironmentUid); - _sendCollectionOauth2Request(collection, environment, collectionCopy.runtimeVariables) + _sendCollectionOauth2Request(collectionCopy, environment, collectionCopy.runtimeVariables) .then((response) => { if (response?.data?.error) { toast.error(response?.data?.error); diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index d08867289..ded75010b 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -741,7 +741,7 @@ const registerNetworkIpc = (mainWindow) => { const collectionRoot = get(collection, 'root', {}); const _request = collectionRoot?.request; - const request = prepareCollectionRequest(_request, collectionRoot, collectionPath); + const request = prepareCollectionRequest(_request, collection, collectionPath); request.__bruno__executionMode = 'standalone'; const envVars = getEnvVars(environment); const processEnvVars = getProcessEnvVars(collectionUid); diff --git a/packages/bruno-electron/src/ipc/network/prepare-collection-request.js b/packages/bruno-electron/src/ipc/network/prepare-collection-request.js index 5fd630594..e4d06c625 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-collection-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-collection-request.js @@ -1,7 +1,8 @@ const { get, each } = require('lodash'); const { setAuthHeaders } = require('./prepare-request'); -const prepareCollectionRequest = (request, collectionRoot) => { +const prepareCollectionRequest = (request, collection) => { + const collectionRoot = get(collection, 'root', {}); const headers = {}; let contentTypeDefined = false; let url = request.url; @@ -34,6 +35,8 @@ const prepareCollectionRequest = (request, collectionRoot) => { }; axiosRequest = setAuthHeaders(axiosRequest, request, collectionRoot); + + axiosRequest.globalEnvironmentVariables = collection?.globalEnvironmentVariables; if (request.script) { axiosRequest.script = request.script;