Files
probo/apps/console/src/utils.ts
gearnode 123a538d82 Embded frontend inside go binary
This will simplify the self hosting of the platform.

Signed-off-by: gearnode <bryan@frimin.fr>
2025-03-09 15:30:28 +01:00

21 lines
410 B
TypeScript

export function buildEndpoint(path: string): string {
const host = process.env.API_SERVER_HOST!;
if (!host) {
return path;
}
const formattedHost =
host.startsWith("http://") || host.startsWith("https://")
? host
: `https://${host}`;
const url = new URL(formattedHost);
if (path) {
url.pathname = path.startsWith("/") ? path : `/${path}`;
}
return url.toString();
}