;s
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
export const API_BASE =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL || "http://127.0.0.1:8000";
|
||||
export const API_BASE = (process.env.NEXT_PUBLIC_API_BASE_URL || "").replace(/\/$/, "");
|
||||
|
||||
export function apiUrl(path: string): string {
|
||||
if (/^https?:\/\//i.test(path)) return path;
|
||||
return `${API_BASE}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
||||
if (API_BASE.endsWith("/api") && normalizedPath.startsWith("/api/")) {
|
||||
return `${API_BASE}${normalizedPath.slice(4)}`;
|
||||
}
|
||||
return `${API_BASE}${normalizedPath}`;
|
||||
}
|
||||
|
||||
export async function apiFetch<T>(
|
||||
|
||||
Reference in New Issue
Block a user