diff --git a/.env b/.env index 2f76afc..fb678cb 100644 --- a/.env +++ b/.env @@ -22,3 +22,6 @@ VITE_INSTANCES_RESOURCE_NAME=v1alpha1 VITE_BFF_URL= VITE_NODE_TERMINAL_DEFAULT_PROFILE=baseline + +VITE_LOGIN_URL=/oauth/token +VITE_LOGOUT_URL=/oauth/logout diff --git a/.env.options.dist b/.env.options.dist index 30d0091..6b0e1c5 100644 --- a/.env.options.dist +++ b/.env.options.dist @@ -24,3 +24,6 @@ INSTANCES_RESOURCE_NAME= BFF_URL= NODE_TERMINAL_DEFAULT_PROFILE= + +VITE_LOGIN_URL= +VITE_LOGOUT_URL= diff --git a/server/index.ts b/server/index.ts index 0f334e3..bd6d6c7 100644 --- a/server/index.ts +++ b/server/index.ts @@ -57,6 +57,9 @@ const BFF_URL = process.env.LOCAL === 'true' ? options?.BFF_URL : process.env.BF const NODE_TERMINAL_DEFAULT_PROFILE = process.env.LOCAL === 'true' ? options?.NODE_TERMINAL_DEFAULT_PROFILE : process.env.NODE_TERMINAL_DEFAULT_PROFILE +const LOGIN_URL = process.env.LOCAL === 'true' ? options?.LOGIN_URL : process.env.LOGIN_URL +const LOGOUT_URL = process.env.LOCAL === 'true' ? options?.LOGOUT_URL : process.env.LOGOUT_URL + const healthcheck = require('express-healthcheck') const promBundle = require('express-prom-bundle') @@ -176,7 +179,9 @@ app.get(`${basePrefix ? basePrefix : ''}/env.js`, (_, res) => { INSTANCES_API_GROUP: ${JSON.stringify(INSTANCES_API_GROUP) || '"check envs"'}, INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'}, INSTANCES_RESOURCE_NAME: ${JSON.stringify(INSTANCES_RESOURCE_NAME) || '"check envs"'}, - NODE_TERMINAL_DEFAULT_PROFILE: ${JSON.stringify(NODE_TERMINAL_DEFAULT_PROFILE) || '"general"'} + NODE_TERMINAL_DEFAULT_PROFILE: ${JSON.stringify(NODE_TERMINAL_DEFAULT_PROFILE) || '"general"'}, + LOGIN_URL: ${JSON.stringify(LOGIN_URL) || '"check envs"'}, + LOGOUT_URL: ${JSON.stringify(LOGOUT_URL) || '"check envs"'} } `, ) diff --git a/src/api/auth.ts b/src/api/auth.ts index 6ee752d..d149cc5 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -1,12 +1,13 @@ import axios, { AxiosResponse } from 'axios' import { TAuthResponse } from 'localTypes/auth' +import { LOGIN_URL, LOGOUT_URL } from 'constants/customizationApiGroupAndVersion' import { handleError } from './handleResponse' export const login = async (): Promise => { let response: AxiosResponse | undefined try { - response = await axios.get('/oauth/token', { withCredentials: true }) + response = await axios.get(LOGIN_URL, { withCredentials: true }) } catch (error) { handleError(error) } @@ -18,7 +19,7 @@ export const logout = async (): Promise => { let response: AxiosResponse | undefined try { - response = await axios.get('/oauth/logout', { withCredentials: true }) + response = await axios.get(LOGOUT_URL, { withCredentials: true }) } catch (error) { handleError(error) } finally { diff --git a/src/constants/customizationApiGroupAndVersion.ts b/src/constants/customizationApiGroupAndVersion.ts index 74f8414..d054e0e 100644 --- a/src/constants/customizationApiGroupAndVersion.ts +++ b/src/constants/customizationApiGroupAndVersion.ts @@ -28,3 +28,6 @@ export const BASE_INSTANCES_RESOURCE_NAME = export const NODE_TERMINAL_DEFAULT_PROFILE = window._env_.NODE_TERMINAL_DEFAULT_PROFILE || import.meta.env.VITE_NODE_TERMINAL_DEFAULT_PROFILE + +export const LOGIN_URL = window._env_.LOGIN_URL || import.meta.env.VITE_LOGIN_URL +export const LOGOUT_URL = window._env_.LOGOUT_URL || import.meta.env.VITE_LOGOUT_URL