I've encountered an issue while working on my Next.js project. Everything runs smoothly in development, but once I build the project for production, the /sitemap.xml URL doesn't return any data.
To address this problem, I created a sitemap.ts file within the /app directory:
import { MetadataRoute } from 'next'
import { getAllNews } from '../app/libs/api/news'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
let news = await getAllNews();
console.log(news)
return [ ...news]
}
Could there be any specific configurations or common issues that I should be aware of when it comes to static generation and sitemap generation in Next.js?