Files

12 lines
572 B
TypeScript
Raw Permalink Normal View History

import type { PublicCategorySummary, PublicSite } from "@imen/shared";
/** Server-side call to the backend API (internal network address) */
export const serverApi = <T>(path: string) =>
$fetch<T>(path, { baseURL: useRuntimeConfig().apiInternalUrl, retry: 1 });
export const fetchCategories = () => serverApi<PublicCategorySummary[]>("/public/categories");
export const fetchSite = () => serverApi<PublicSite>("/public/site");
/** Absolute URL on the production domain */
export const absUrl = (p: string) => new URL(p, useRuntimeConfig().public.siteUrl).toString();