refactor: export joinUrl from auth/api and reuse in lib/api
Single source of truth for the VITE_API_BASE_URL prefix logic. Both auth/api and lib/api imported the same BASE_URL const; promote joinUrl to a shared exported helper so future endpoints don't drift on the trailing-slash normalization.
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
|
const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
|
||||||
|
|
||||||
function joinUrl(path: string): string {
|
export function joinUrl(path: string): string {
|
||||||
if (BASE_URL) return `${BASE_URL.replace(/\/$/, "")}${path}`;
|
if (BASE_URL) return `${BASE_URL.replace(/\/$/, "")}${path}`;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import type {
|
|||||||
import {
|
import {
|
||||||
authedFetch,
|
authedFetch,
|
||||||
authedFetchResponse,
|
authedFetchResponse,
|
||||||
|
joinUrl,
|
||||||
} from "@/auth/api";
|
} from "@/auth/api";
|
||||||
|
|
||||||
const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
|
const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
|
||||||
|
|||||||
Reference in New Issue
Block a user