From 67216579bc3d9039f2e59f8c83f5e84c015f6fb1 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 25 Jan 2024 14:24:30 +0100 Subject: [PATCH] fix(auth): correctly construct redirect url from current window href --- src/helpers/redirectToProvider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers/redirectToProvider.ts b/src/helpers/redirectToProvider.ts index 2df546d51a..efd1f622f4 100644 --- a/src/helpers/redirectToProvider.ts +++ b/src/helpers/redirectToProvider.ts @@ -1,11 +1,13 @@ import {createRandomID} from '@/helpers/randomId' import type {IProvider} from '@/types/IProvider' +import {parseURL} from 'ufo' export const redirectToProvider = (provider: IProvider) => { // We're not using the redirect url provided by the server to allow redirects when using the electron app. // The implications are not quite clear yet hence the logic to pass in another redirect url still exists. - const redirectUrl = `${window.location.href.replace('/login', '')}/auth/openid/` + const url = parseURL(window.location.href) + const redirectUrl = `${url.protocol}//${url.host}/auth/openid/` const state = createRandomID(24) localStorage.setItem('state', state)