From 0318db1027ed5311e9bd052bd501b83f6d634833 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sat, 26 Jul 2025 16:31:51 +0200 Subject: [PATCH] Build redirect uri dynamically when needed. It will allows compatibility with multi hostname envs. --- frontend/public/config.json | 2 +- frontend/src/stores/auth.store.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/public/config.json b/frontend/public/config.json index c3d464b21..5de521980 100644 --- a/frontend/public/config.json +++ b/frontend/public/config.json @@ -3,6 +3,6 @@ "API_DOC_URL": "/api/schema-v2/swagger/", "OAUTH_AUTHORITY_URL": "https://localhost:8000/api/o", "OAUTH_CLIENT_ID": "LVQbfIIX3khWR3nDvix1u9yEGHZUxcx53bhJ7FlD", - "OAUTH_REDIRECT_URI": "https://localhost:3000/login/logged", + "OAUTH_REDIRECT_URI": "/login/logged", "OAUTH_POST_REDIRECT_URI": "https://localhost:3000/" } diff --git a/frontend/src/stores/auth.store.js b/frontend/src/stores/auth.store.js index 886b4ca1d..1affc66c6 100644 --- a/frontend/src/stores/auth.store.js +++ b/frontend/src/stores/auth.store.js @@ -17,10 +17,15 @@ export const useAuthStore = defineStore('auth', () => { const config = useGlobalConfig() const authUser = ref(null) const isAuthenticated = ref(false) + let redirectUri = config.OAUTH_REDIRECT_URI + + if (!redirectUri.startsWith('http')) { + redirectUri = `${location.protocol}//${location.host}${redirectUri}` + } const manager = new UserManager({ authority: config.OAUTH_AUTHORITY_URL, client_id: config.OAUTH_CLIENT_ID, - redirect_uri: config.OAUTH_REDIRECT_URI, + redirect_uri: redirectUri, post_logout_redirect_uri: config.OAUTH_POST_REDIRECT_URI, response_type: 'code', scope: 'openid read write',