I'm facing an issue with my Next.js 13 application's router involving dynamic routes and the generation of static pages. I've successfully implemented a dynamic route to fetch a single item using its product ID, utilizing generateStaticPaths. However, I've encountered an unexpected behavior after deploying my project. New product pages are being created with a .txt extension instead of the expected .html extension.
Here's a snippet of the relevant code from my project:
async function getProduct(id) {
const product = await fetch(
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/store/${id}`
).then((res) => res.json());
return product;
}
export async function generateStaticParams() {
const products = await fetch(
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/store/`
).then((res) => res.json());
return products.map((product) => ({
id: product._id,
}));
}
const SingleStore = async ({ params: { id } }) => {
const product = await getProduct(id);
const removePTags = (text) => {
const regex = /<p[^>]*>(.*?)<\/p>/g;
return text?.replace(regex, '$1');
};
return ( <h1>My product Implementation </h1> )
}
I expect that when new products are added to the product list after the project has been built and deployed, the new product pages should be created with a .html extension, just like the existing product pages.
However, after deploying the project, new product pages are being generated with a .txt extension, which is causing unexpected behavior and broken links.