forked from UKSOURCE/hailearning.edu.vn
fix: update image URL handling to support paths without leading slashes and clean up layout file
This commit is contained in:
@@ -22,7 +22,6 @@ export default function RootLayout({
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="shortcut icon" href="/assets/img/favicon.png" />
|
||||
|
||||
<link rel="stylesheet" href="/assets/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="/assets/css/all.min.css" />
|
||||
<link rel="stylesheet" href="/assets/css/animate.css" />
|
||||
|
||||
@@ -14,9 +14,18 @@ export function getCmsImageUrl(imagePath: string | undefined): string {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
if (imagePath.startsWith("/uploads/") || imagePath.startsWith("/img/")) {
|
||||
// Hỗ trợ cả "/uploads/", "uploads/", "/img/", "img/"
|
||||
if (
|
||||
imagePath.startsWith("/uploads/") ||
|
||||
imagePath.startsWith("uploads/") ||
|
||||
imagePath.startsWith("/img/") ||
|
||||
imagePath.startsWith("img/")
|
||||
) {
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
||||
return `${apiUrl}${imagePath}`;
|
||||
// Nếu thiếu dấu "/" đầu, thêm vào cho đúng path
|
||||
const fixedPath =
|
||||
imagePath.startsWith("/") ? imagePath : `/${imagePath}`;
|
||||
return `${apiUrl}${fixedPath}`;
|
||||
}
|
||||
|
||||
if (imagePath.startsWith("/")) {
|
||||
|
||||
Reference in New Issue
Block a user