Move constants, add API URL, and implement file URL helper

Relocated common constants to a new "lib/constants" directory for better organization. Added BACKEND_API_URL constant to manage API base URL dynamically. Introduced a utility function `getServerFileUrl` to generate file URLs using the backend API.
This commit is contained in:
2025-03-14 01:17:02 +01:00
parent ffdf095eee
commit 058b2b3c73
3 changed files with 6 additions and 0 deletions

View File

@@ -1 +1,2 @@
export const RESERVED_SLUGS = ["new", "edit", "delete", "settings"];
export const BACKEND_API_URL = process.env.NEXT_PUBLIC_API_URL;

View File

@@ -1,5 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { BACKEND_API_URL } from "@/lib/constants";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@@ -65,3 +66,7 @@ export function formatTime(
minute: "2-digit",
});
}
export const getServerFileUrl = (url?: string) => {
return url ? `${BACKEND_API_URL}/files/${url}` : undefined;
};