Skip to content
Snippets Groups Projects
Commit 45a90332 authored by Luka's avatar Luka
Browse files

Fix logout link to be dynamically generated

parent 046eb3d5
No related branches found
No related tags found
No related merge requests found
REACT_APP_API_URL=http://stackspin_proxy:8081/api/v1
REACT_APP_HYDRA_PUBLIC_URL=https://sso.init.stackspin.net
import React, { Fragment, useState } from 'react';
import React, { Fragment, useMemo, useState } from 'react';
import { Disclosure, Menu, Transition } from '@headlessui/react';
import { MenuIcon, XIcon } from '@heroicons/react/outline';
import { useAuth } from 'src/services/auth';
......@@ -26,8 +26,6 @@ function filterNavigationByDashboardRole(isAdmin: boolean) {
return navigation.filter((item) => !item.requiresAdmin);
}
const HYDRA_URL = process.env.REACT_APP_HYDRA_PUBLIC_URL;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface HeaderProps {}
......@@ -50,7 +48,15 @@ const Header: React.FC<HeaderProps> = () => {
const navigationItems = filterNavigationByDashboardRole(isAdmin);
const signOutUrl = `${HYDRA_URL}/oauth2/sessions/logout`;
// eslint-disable-next-line react-hooks/exhaustive-deps
const signOutUrl = useMemo(() => {
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 `https://sso.${hostname.replace('dashboard', '')}/oauth2/sessions/logout`;
}, []);
return (
<>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment