Error occurred prerendering page "/sitemap.xml"
Unanswered
Citrine Wagtail posted this in #help-forum
Citrine WagtailOP
i have this inside app/sitemap.ts
i was trying to dynamically generate sitemaps with the help of the docs from next js, so the sitemaps are perfectly fine on development but it gives this error while i try to deploy it to the vercel
import { getData } from "@/lib/meta";
import { Blog } from "@/utils";
export default async function sitemap() {
const posts = await getData();
const baseUrl = "https://enigma.fm";
const postUrls = posts.map((post: Blog) => ({
url: `${baseUrl}/community/blogs/${post.slug.current}`,
lastModified: new Date(post.publishedAt),
}));
const uniqueAuthors = new Set(
posts.map((post: Blog) => post.author.slug.current)
);
const authorUrls = Array.from(uniqueAuthors).map((authorSlug) => ({
url: `${baseUrl}/community/author/${authorSlug}`,
lastModified: new Date(),
}));
return [
{
url: baseUrl,
lastModified: new Date(),
},
{
url: `${baseUrl}/pricing`,
lastModified: new Date(),
},
{
url: `${baseUrl}/profile`,
lastModified: new Date(),
},
{
url: `${baseUrl}/signup`,
lastModified: new Date(),
},
{
url: `${baseUrl}/signin`,
lastModified: new Date(),
},
{
url: `${baseUrl}/success`,
lastModified: new Date(),
},
{
url: `${baseUrl}/privacy`,
lastModified: new Date(),
},
{
url: `${baseUrl}/refund`,
lastModified: new Date(),
},
{
url: `${baseUrl}/terms`,
lastModified: new Date(),
},
{
url: `${baseUrl}/community`,
lastModified: new Date(),
},
...postUrls,
...authorUrls,
];
}
i was trying to dynamically generate sitemaps with the help of the docs from next js, so the sitemaps are perfectly fine on development but it gives this error while i try to deploy it to the vercel
4 Replies
Citrine WagtailOP
please atleast help me out with this one
Citrine WagtailOP
Guys anyone?
Citrine WagtailOP
wow no one gonna respond ?
Bombay
Hello, a bit late, but try to force dynamic:
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
If not I know it's a bit hacky but try to use the experimental build mode:
https://nextjs.org/docs/pages/api-reference/cli/next
And see if it then works live/prod deployed.
I hope this helps
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
If not I know it's a bit hacky but try to use the experimental build mode:
https://nextjs.org/docs/pages/api-reference/cli/next
And see if it then works live/prod deployed.
I hope this helps