fix(utils): fix APIUrlGenerator undefined base URL issue

- Replace import.meta.env.VITE_APP_BACKEND_BASE_URL with API_GATE_WAY constant
- Ensure API URLs are generated correctly without undefined segments
- Fix API endpoint URL construction
This commit is contained in:
hosseintaromi 2025-07-21 23:36:13 +03:30
parent 9b39a4ac47
commit 2a5875fd40
1 changed files with 2 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import { getAuth } from "@/pages/auth";
import { pageSize } from "@/constant/generalVariables"; import { pageSize } from "@/constant/generalVariables";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { postLogout } from "@/pages/auth/core/_requests"; import { postLogout } from "@/pages/auth/core/_requests";
const baseURL = API_GATE_WAY; const baseURL = API_GATE_WAY;
axios.defaults.baseURL = API_GATE_WAY; axios.defaults.baseURL = API_GATE_WAY;
axios.defaults.timeout = REQUEST_TIMEOUT; axios.defaults.timeout = REQUEST_TIMEOUT;
@ -149,9 +150,7 @@ export function APIUrlGenerator(
): string { ): string {
const query = qry || {}; const query = qry || {};
const queryKeys = Object.keys(query); const queryKeys = Object.keys(query);
let apiUrl = `${ let apiUrl = `${baseUrl || API_GATE_WAY}/${route}`;
baseUrl ? baseUrl : import.meta.env.VITE_APP_BACKEND_BASE_URL
}/${route}`;
queryKeys.forEach((item, index) => { queryKeys.forEach((item, index) => {
if (index === 0) { if (index === 0) {
apiUrl += "?"; apiUrl += "?";