Skip to content

Commit

Permalink
Fix redirect URL on 401s (#5230)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhsaxena authored Jun 17, 2021
1 parent 1134265 commit 75481e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/client/src/api/ApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 75481e9

Please sign in to comment.