diff --git a/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts b/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts index 5e046bce7e92..7a6dfd97b020 100644 --- a/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts +++ b/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts @@ -35,9 +35,7 @@ import { DEFAULT_FETCH_RETRY_OPTIONS, DEFAULT_BASE_URL } from './constants'; const defaultUnauthorizedHandler = () => { if (!window.location.pathname.startsWith('/login')) { - window.location.href = `/login?next=${ - window.location.pathname + window.location.search - }`; + window.location.href = `/login?next=${window.location.href}`; } }; diff --git a/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts b/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts index a17cbceb223d..ef31e5d35d85 100644 --- a/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts @@ -505,8 +505,7 @@ describe('SupersetClientClass', () => { const mockRequestUrl = 'https://host/get/url'; const mockRequestPath = '/get/url'; const mockRequestSearch = '?param=1¶m=2'; - const mockRequestRelativeUrl = mockRequestPath + mockRequestSearch; - const mockHref = `http://localhost${mockRequestRelativeUrl}`; + const mockHref = mockRequestUrl + mockRequestSearch; beforeEach(() => { originalLocation = window.location; @@ -542,7 +541,7 @@ describe('SupersetClientClass', () => { error = err; } finally { const redirectURL = window.location.href; - expect(redirectURL).toBe(`/login?next=${mockRequestRelativeUrl}`); + expect(redirectURL).toBe(`/login?next=${mockHref}`); expect(error.status).toBe(401); } });