koperasi/services/frontend/app/utils/prefix-file-path.ts

14 lines
338 B
TypeScript
Raw Permalink Normal View History

2025-08-08 07:12:40 +00:00
import getEnv from "~/lib/get-env";
export function formatImagePath(imagePath: string): string {
const env = getEnv();
const isExternalImage = imagePath.startsWith("http") || imagePath.startsWith("https");
const baseUrl = env.API_BASE_URL;
if (isExternalImage) {
return imagePath;
}
return `${baseUrl}/${imagePath}`;
}