forked from UKSOURCE/hailearning.edu.vn
feat: refactor service API schema and update layout structure
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
export const imageUrl = (path?: string) => {
|
||||
if (!path) return "";
|
||||
// Không có ảnh → ảnh mặc định
|
||||
if (!path) return "/_images/default.jpg";
|
||||
|
||||
// Đã là full URL
|
||||
if (path.startsWith("http")) return path;
|
||||
return `${process.env.NEXT_PUBLIC_API_URL}/${path}`;
|
||||
|
||||
const base = (
|
||||
process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"
|
||||
).replace(/\/$/, "");
|
||||
|
||||
return `${base}/${path.replace(/^\//, "")}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user