From 0ae455f3d285e0649da46553c762292866c4f727 Mon Sep 17 00:00:00 2001 From: Wini_Fy Date: Thu, 5 Feb 2026 21:38:48 +0700 Subject: [PATCH] fix: update blog post URL handling to use API base URL instead of site URL --- app/blog/[slug]/components/NewsDetailsContent.tsx | 7 ++----- app/blog/[slug]/page.tsx | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/blog/[slug]/components/NewsDetailsContent.tsx b/app/blog/[slug]/components/NewsDetailsContent.tsx index dc915a8..11bf29d 100644 --- a/app/blog/[slug]/components/NewsDetailsContent.tsx +++ b/app/blog/[slug]/components/NewsDetailsContent.tsx @@ -12,12 +12,9 @@ export default function NewsDetailsContent({ post }: NewsDetailsContentProps) { // Lấy comments từ post (đã được bao gồm trong API response) const postComments = post.comments || []; - // Lấy base URL cho EditorJS images + // Lấy base URL cho EditorJS images và URL tuyệt đối của bài viết const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"; - - // URL tuyệt đối của bài viết để share lên mạng xã hội - const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"; - const postUrl = `${siteUrl}/blog/${post.slug}`; + const postUrl = `${baseUrl}/blog/${post.slug}`; const encodedPostUrl = encodeURIComponent(postUrl); const encodedTitle = encodeURIComponent(post.title); diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx index 31ab061..10ea765 100644 --- a/app/blog/[slug]/page.tsx +++ b/app/blog/[slug]/page.tsx @@ -48,11 +48,11 @@ export async function generateMetadata({ const blogResponse = await fetchBlogDetail(slug); const post = blogResponse.data; - const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"; - const url = `${siteUrl}/blog/${post.slug}`; + const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"; + const url = `${apiUrl}/blog/${post.slug}`; const imageUrl = post.featuredImage ? getCmsImageUrl(post.featuredImage) - : `${siteUrl}/assets/img/inner-page/news-details/details-1.jpg`; + : `${apiUrl}/assets/img/inner-page/news-details/details-1.jpg`; return { title: post.title,