From 75481e93d20678d3d24642a7f404ca0e913d4e8c Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Thu, 17 Jun 2021 22:50:32 +0530 Subject: [PATCH] Fix redirect URL on 401s (#5230) --- app/client/src/api/ApiUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/client/src/api/ApiUtils.ts b/app/client/src/api/ApiUtils.ts index 475a7a3119..81f94cca20 100644 --- a/app/client/src/api/ApiUtils.ts +++ b/app/client/src/api/ApiUtils.ts @@ -14,6 +14,7 @@ import log from "loglevel"; import { ActionExecutionResponse } from "api/ActionAPI"; import store from "store"; import { logoutUser } from "actions/userActions"; +import { AUTH_LOGIN_URL } from "constants/routes"; const executeActionRegex = /actions\/execute/; const timeoutErrorRegex = /timeout of (\d+)ms exceeded/; @@ -101,7 +102,11 @@ export const apiFailureResponseInterceptor = (error: any) => { if (error.response.status === API_STATUS_CODES.REQUEST_NOT_AUTHORISED) { // Redirect to login and set a redirect url. store.dispatch( - logoutUser({ redirectURL: encodeURIComponent(currentUrl) }), + logoutUser({ + redirectURL: `${AUTH_LOGIN_URL}?redirectUrl=${encodeURIComponent( + currentUrl, + )}`, + }), ); return Promise.reject({ code: ERROR_CODES.REQUEST_NOT_AUTHORISED,