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:
@@ -1 +1,2 @@
|
||||
export const RESERVED_SLUGS = ["new", "edit", "delete", "settings"];
|
||||
export const BACKEND_API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user