Next.js Discord

Discord Forum

Dynamic Route Working Inconsistently on Production – Some Slugs Work, Some Show 404

Unanswered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
Hi everyone! I’m facing an issue with dynamic routes in my Next.js 15 app.

🧩 Problem:
I’m using generateStaticParams() to generate dynamic routes for a tender detail page.

Locally, everything works fine — all routes load correctly.

But in production (output: export), some routes work, and others show the "not found" page.

Newly added tender slugs also show 404 after deployment.

✅ What I’ve tried:
I confirmed that generateStaticParams() is returning all slugs.

I can see all slugs being logged during build time.

I removed dynamicParams: true because it’s not supported with output: export.

❓ What I want:
I want all dynamic routes to work — including newly added tenders after deployment.

Is this possible using output: export?

Here’s my route code:

// [slug]/page.tsx

export async function generateStaticParams() {
const res = await fetch(${process.env.NEXT_PUBLIC_BASE_URL}/get-tenders-by-search?tender_category=tender&page=1);
const data = await res.json();

let allTenders = data?.data?.data [];
const totalPages = data?.data?.last_page
1;

for (let page = 2; page <= totalPages; page++) {
const nextRes = await fetch(${process.env.NEXT_PUBLIC_BASE_URL}/get-tenders-by-search?tender_category=tender&page=${page});
const nextData = await nextRes.json();
allTenders = [...allTenders, ...(nextData?.data?.data || [])];
}

return allTenders.map((tender) => ({ slug: tender.slug }));
}


Any idea why some slugs work and some don’t? Or what’s the best way to support new slugs in a static export setup?

Thanks in advance 🙏

0 Replies