forked from UKSOURCE/hailearning.edu.vn
Merge pull request 'fix: blog dynamic build' (#27) from fea/thanh-02022026-news into main
Reviewed-on: UKSOURCE/hailearning.edu.vn#27
This commit is contained in:
@@ -15,10 +15,10 @@ export const aboutApi = {
|
|||||||
try {
|
try {
|
||||||
const apiUrl = getApiUrl();
|
const apiUrl = getApiUrl();
|
||||||
const response = await fetch(`${apiUrl}/api/about`, {
|
const response = await fetch(`${apiUrl}/api/about`, {
|
||||||
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
headers: {
|
headers: {
|
||||||
'Cache-Control': 'no-cache',
|
'Content-Type': 'application/json',
|
||||||
'Pragma': 'no-cache'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ export const fetchBlogList = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// Next.js: cache và revalidate (disabled)
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// next: { revalidate: 60 }, // Revalidate mỗi 60 giây
|
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,8 +89,7 @@ export const fetchBlogDetail = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// No cache for blog detail (disabled caching)
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -131,8 +128,7 @@ export const fetchFeaturedBlogs = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 60 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -168,8 +164,7 @@ export const fetchRecentBlogs = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 60 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -202,8 +197,7 @@ export const fetchCategories = async (): Promise<CategoryListResponse> => {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 300 }, // Categories ít thay đổi, cache lâu hơn
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -239,8 +233,7 @@ export const fetchCategoryDetail = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 300 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -276,8 +269,7 @@ export const fetchTags = async (): Promise<TagListResponse> => {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 300 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -313,8 +305,7 @@ export const fetchPopularTags = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 300 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -350,8 +341,7 @@ export const fetchTagDetail = async (
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
// next: { revalidate: 300 },
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
// no-cache
|
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ export const fetchServicePageData = async (): Promise<ServicePageData> => {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
|
cache: "no-store",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Services API response status:", response.status);
|
console.log("Services API response status:", response.status);
|
||||||
@@ -179,6 +181,8 @@ export const fetchServiceBySlug = async (slug: string): Promise<any> => {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
// Không cache - luôn fetch dữ liệu mới nhất
|
||||||
|
cache: "no-store",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Response status:", response.status);
|
console.log("Response status:", response.status);
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { AboutHero, AboutIntro, AboutMission, AboutFeatures, AboutNews } from "../components/about";
|
import { AboutHero, AboutIntro, AboutMission, AboutFeatures, AboutNews } from "../components/about";
|
||||||
import { aboutApi } from "../../api/aboutApi";
|
import { aboutApi } from "../../api/aboutApi";
|
||||||
|
|
||||||
|
// Force dynamic rendering - không cache
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function AboutPage() {
|
export default async function AboutPage() {
|
||||||
const data = await aboutApi.getAbout();
|
const data = await aboutApi.getAbout();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { fetchBlogList, fetchBlogDetail } from "@/api/blogsApi";
|
|||||||
import Sidebar from "@/app/blog/components/Sidebar";
|
import Sidebar from "@/app/blog/components/Sidebar";
|
||||||
import { getCmsImageUrl } from "@/utils";
|
import { getCmsImageUrl } from "@/utils";
|
||||||
|
|
||||||
|
// Force dynamic rendering - không cache
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
// Generate static params for all blog posts
|
// Generate static params for all blog posts
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import localHomeData from './home.json';
|
|||||||
import { getCmsImageUrl } from '@/utils/image';
|
import { getCmsImageUrl } from '@/utils/image';
|
||||||
import { fetchHomeData } from '@/api';
|
import { fetchHomeData } from '@/api';
|
||||||
|
|
||||||
|
// Force dynamic rendering - không cache
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function Home() {
|
export default async function Home() {
|
||||||
// Fetch home data (blog aggregation is now handled by the backend)
|
// Fetch home data (blog aggregation is now handled by the backend)
|
||||||
const apiHomeData = await fetchHomeData();
|
const apiHomeData = await fetchHomeData();
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import Breadcrumb from "../components/Breadcrumb";
|
|||||||
import ImageWithFallback from "../components/ImageWithFallback";
|
import ImageWithFallback from "../components/ImageWithFallback";
|
||||||
import "./services.css";
|
import "./services.css";
|
||||||
|
|
||||||
|
// Force dynamic rendering - không cache
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function ServicesPage() {
|
export default async function ServicesPage() {
|
||||||
const data = await fetchServicePageData();
|
const data = await fetchServicePageData();
|
||||||
const allCountries = await fetchCountries();
|
const allCountries = await fetchCountries();
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
import Breadcrumb from "../components/Breadcrumb";
|
import Breadcrumb from "../components/Breadcrumb";
|
||||||
import { fetchVisaData, type VisaCountry } from "@/api/visa";
|
import { fetchVisaData, type VisaCountry } from "@/api/visa";
|
||||||
|
|
||||||
|
// Force dynamic rendering - không cache
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function VisaListPage() {
|
export default async function VisaListPage() {
|
||||||
// Fetch all visa countries từ API
|
// Fetch all visa countries từ API
|
||||||
let visaCountries: any[] = [];
|
let visaCountries: any[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user