diff --git a/ui/src/utils/auth.ts b/ui/src/utils/auth.ts index c0b2230..87bd6f7 100755 --- a/ui/src/utils/auth.ts +++ b/ui/src/utils/auth.ts @@ -3,7 +3,18 @@ const clientIdItemKey = 'client-id' const accessTokenItemKey = 'ACCESS_TOKEN' -const auth = { +const auth = { + getApiUrl() { + let HTTP_URL = '' + if (process.env.NODE_ENV !== 'production') { + HTTP_URL = import.meta.env.APP_URL; + } else { + const host: any = document.querySelector('meta[name="host"]') + HTTP_URL = host.getAttribute('content'); + } + return HTTP_URL + }, + getClientId() { return window.localStorage.getItem(clientIdItemKey) }, @@ -15,7 +26,7 @@ const auth = { getAccessToken() { return window.localStorage.getItem(accessTokenItemKey) }, - + resetToken() { const token = window.localStorage.getItem(accessTokenItemKey); if (token) { @@ -36,7 +47,7 @@ const auth = { window.localStorage.setItem(accessTokenItemKey, accessToken) } }, -} +} export default auth; diff --git a/ui/src/utils/http/http.ts b/ui/src/utils/http/http.ts index 9f2306f..f22daeb 100644 --- a/ui/src/utils/http/http.ts +++ b/ui/src/utils/http/http.ts @@ -11,7 +11,7 @@ const HttpCodes = { } export default new Request({ - baseUrl: import.meta.env.APP_URL, + baseUrl: Auth.getApiUrl(), headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'