From d0b86c08092742e0cba01daa332cab165f6189fa Mon Sep 17 00:00:00 2001
From: Luka Radenovic <luka@init.hr>
Date: Wed, 13 Jul 2022 14:59:15 +0200
Subject: [PATCH] Add HYDRA_PUBLIC_URL env variable and fix replace of sing out
 url

---
 .env.example                     | 1 +
 src/components/Header/Header.tsx | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.env.example b/.env.example
index c32c7c4c..f3afcc4b 100644
--- a/.env.example
+++ b/.env.example
@@ -1 +1,2 @@
 REACT_APP_API_URL=http://stackspin_proxy:8081/api/v1
+REACT_APP_HYDRA_PUBLIC_URL=https://sso.init.stackspin.net
\ No newline at end of file
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index 7e677304..97a24eda 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -9,6 +9,8 @@ import _ from 'lodash';
 
 import { UserModal } from '../UserModal';
 
+const HYDRA_LOGOUT_URL = `${process.env.REACT_APP_HYDRA_PUBLIC_URL}/oauth2/sessions/logout`;
+
 const navigation = [
   { name: 'Dashboard', to: '/dashboard', requiresAdmin: false },
   { name: 'Users', to: '/users', requiresAdmin: true },
@@ -52,9 +54,9 @@ const Header: React.FC<HeaderProps> = () => {
     const { hostname } = window.location;
     // If we are developing locally, we need to use the init cluster's public URL
     if (hostname === 'localhost') {
-      return `https://sso.init.stackspin.net/oauth2/sessions/logout`;
+      return HYDRA_LOGOUT_URL;
     }
-    return `https://${hostname.replace('dashboard', 'sso')}/oauth2/sessions/logout`;
+    return `https://${hostname.replace(/^dashboard/, 'sso')}/oauth2/sessions/logout`;
   }, []);
 
   return (
-- 
GitLab