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