forked from UKSOURCE/hailearning.edu.vn
feat: Implement blog API service and refactor components for improved data fetching
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Rules:
|
||||
* - If already a full URL (http/https) → return as is
|
||||
* - If starts with `/uploads/` → prepend API URL (NEXT_PUBLIC_API_URL or default localhost)
|
||||
* - If starts with `/uploads/` or `/img/` → prepend API URL (NEXT_PUBLIC_API_URL or default localhost)
|
||||
* - If starts with `/` → use as-is (served by Next/public)
|
||||
* - Otherwise → treat as relative path under `/`
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ export function getCmsImageUrl(imagePath: string | undefined): string {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
if (imagePath.startsWith("/uploads/")) {
|
||||
if (imagePath.startsWith("/uploads/") || imagePath.startsWith("/img/")) {
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
||||
return `${apiUrl}${imagePath}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user