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) ?? "";
|
||||
|
||||
function joinUrl(path: string): string {
|
||||
export function joinUrl(path: string): string {
|
||||
if (BASE_URL) return `${BASE_URL.replace(/\/$/, "")}${path}`;
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import type {
|
||||
import {
|
||||
authedFetch,
|
||||
authedFetchResponse,
|
||||
joinUrl,
|
||||
} from "@/auth/api";
|
||||
|
||||
const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
|
||||
|
||||
Reference in New Issue
Block a user