Disable dynamic sitemap revalidation on preview
Unanswered
Tomistoma posted this in #help-forum
TomistomaOP
Hi there! For my dynamic sitemap (
And for production env, this works fine. It never gets revalidated again, until I hit another build.
The issue is: For preview, it sometimes starts a revalidation (see attached screenshot of the logs), which then always fails with
Is there a way to get Vercel to never revalidate the sitemap on Preview? I just want to avoid all the error log noise. Or do I have to re-implement my function to be a prebuild script that stores a
Thanks in advance!
/app/sitemap.ts
), I use fs.readdirSync
to dynamically get all of the route files and generate all sitemap entries. This works perfectly fine on build. I never want this to run in runtime. So I addedexport const dynamic = 'force-static'
And for production env, this works fine. It never gets revalidated again, until I hit another build.
The issue is: For preview, it sometimes starts a revalidation (see attached screenshot of the logs), which then always fails with
Error: ENOENT: no such file or directory, scandir '/var/task/app'
(which is okay, since I know that in runtime the files are not accessible anymore).Is there a way to get Vercel to never revalidate the sitemap on Preview? I just want to avoid all the error log noise. Or do I have to re-implement my function to be a prebuild script that stores a
sitemap.xml
into the /public
folder during build? Thanks in advance!