From e10d3886c2669d478de1d2da13e26f2ab5705bf1 Mon Sep 17 00:00:00 2001 From: Nora Date: Thu, 2 Jul 2026 11:18:22 -0600 Subject: [PATCH] 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. --- src/auth/api.ts | 2 +- src/lib/api.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/auth/api.ts b/src/auth/api.ts index fa81e90..b281a81 100644 --- a/src/auth/api.ts +++ b/src/auth/api.ts @@ -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; } diff --git a/src/lib/api.ts b/src/lib/api.ts index 151e488..3bc94e6 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -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) ?? "";