sitemap.ts broken in production (HELP)
Answered
Giant panda posted this in #help-forum
Giant pandaOP
HI, I just noticed my sitemap.xml page (sitemap.ts) actually does not work. Even when I copy it straight from the docs I get this weird page!
During dev it works fine. Only not on build!
I hope anyone can help me out with this! I see previous issues seem to be unresolved!
15.4.5
I also completely removed middleware for testing. Nothing works!
During dev it works fine. Only not on build!
I hope anyone can help me out with this! I see previous issues seem to be unresolved!
15.4.5
import type { MetadataRoute } from 'next'
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: 'https://acme.com',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
},
{
url: 'https://acme.com/about',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
{
url: 'https://acme.com/blog',
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.5,
},
]
}
I also completely removed middleware for testing. Nothing works!
Answered by Giant panda
My cache handler inplementation(nescha) incorrectly stores the xml route
10 Replies
Giant pandaOP
I found the issue! createNextIntlPlugin(); from next intl, causes the sitemap.xml page to break!
Anyone who knows how to fix this but still use this method in next.config.ts?
Giant pandaOP
Alright I found:
sitemap.ts works fine!, react-intl has nothing to do with it.
When the sitemap.xml is cached, (nescha cache handler). The page breaks and shows:
sitemap.ts works fine!, react-intl has nothing to do with it.
When the sitemap.xml is cached, (nescha cache handler). The page breaks and shows:
What can I do to fix this? Hope someone reads this!
Please try to create a minimal, reproducible example.
I have a similar thing, but it doesn't seem broken:
https://github.com/tszhong0411/nelsonlai.me/blob/6bfcc113530c8f9134b4c59f621d6dbe1add2342/apps/web/src/app/sitemap.ts
I have a similar thing, but it doesn't seem broken:
https://github.com/tszhong0411/nelsonlai.me/blob/6bfcc113530c8f9134b4c59f621d6dbe1add2342/apps/web/src/app/sitemap.ts
Giant pandaOP
Found the issue.
Giant pandaOP
My cache handler inplementation(nescha) incorrectly stores the xml route
Answer
Giant pandaOP
Forcing the page dynamic solved it for me:)
Grass carp
@Giant panda Can i ask what is the use of sitemap, like is it very essential thing ? how it helps
I am a mobile developer so just wondering