next.js: sitemap in google search console says "Couldn't fetch"
Discussed in https://github.com/vercel/next.js/discussions/75774
<div type='discussions-op-text'>Originally posted by CodingReaper1 February 6, 2025
Link to the code that reproduces this issue
https://github.com/CodingReaper1/TheWildOasisAdminNextJs
To Reproduce
you don’t need to reproduce I think
Current vs. Expected behavior
So I have created dynamic sitemap in nextjs which you can isee in my github repo in app folder problem is no matter what I can’t successfully register sitemap on google search console.
I have seen discussion about this in github already https://github.com/vercel/next.js/issues/51649 however it said that I should create new issue.
I have tried everything shown in that github discussion
I went here www.xml-sitemaps.com/validate-xml-sitemap.html to test sitemap no issues there
I tried adding forward / or search queries in case request was cached
I do have middleware I have page “/sitemap.xlm” in public routes then I tried completly disabling middleware on sitemap page but that didn’t work either I have no idea what to do.
Provide environment information
operating system: windows 10
nextjs: 14
react: 18
you can see all packages in repo
live app if that helps somehow: the-wild-oasis-admin-nextjs.vercel.app
Which area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
No response</div>
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 26 (2 by maintainers)
I found a solution. Just add a slash at the end.
Just update
to
Hope this can help.
https://calcly.xyz/sitemap.xml?force=1
Adding a parameter force=1 solved my problem.
This solved for me!
I completely forgot about this issue, because I started working on another project Nothing is changed on me I made some changes, but sitemap should be valid, but is not
I actually uploaded another demo app which is part of the first application, which has same kind of issue?
I did fix the issue so I have no idea why is it still showing this 10 errors
Maybe it is actually uploaded but it doesn’t show here because of cache?
I attempted all the “fixes” suggested in this issue and many others, but none resolved the problem. For context, I use
next-sitemapto generate sitemaps androbots.txtat build time.I noticed @Joffey say they had success, but also noticed they use a custom domain, so I figured I would try that, and it worked.
So the only solution that worked for me was adding my own custom domain to the deployment and setting up redirects, like so:
https://steamgameidler.vercel.app → 301 redirect → https://steamgameidler.com
https://www.steamgameidler.com → 301 redirect → https://steamgameidler.com
https://steamgameidler.com → Production
After that, I added the custom domain as a property in GSC and successfully submitted the full domain and sitemap route without issues.
When using a
vercel.appdomain, GSC requires selecting “URL Prefix” instead of “Domain” as the property type. This may limit sitemap submissions because the root domain (vercel.app) is predefined. I don’t know how or why this would be an issue, but it’s my best guess, because other than the redirects, the only differences are:With a

vercel.appproperty, GSC allows only the sitemap route (e.g.,/sitemap.xml):With a custom domain property, you can submit the full domain and route (e.g.,

https://steamgameidler.com/sitemap.xml):I still cannot get the sitemap to work with the
vercel.appproperty. Why? Not a clue. But based on these findings, it seems the issue might be with howvercel.appdomains are handled in GSC.The issue is that Google search console expects a xml file with utf-8 encoded and also cors should not block the request, so just head over to next.config.js and add these headers
async headers() { return [ { source: '/sitemap.xml', headers: [ { key: 'Content-Type', value: 'text/xml; charset=utf-8', }, { key: 'Access-Control-Allow-Origin', value: '*' }, { key: 'Access-Control-Allow-Methods', value: '*' }, { key: 'Access-Control-Allow-Headers', value: '*' } ], }, ]; }and this should work fine
Interesting… I tried every single suggested solution, including changing the sitemap file name, but nothing worked.
Where did u add / if u mean google search console it doesn’t work even after all this time it still says couldn’t fetch This is beyond stupid at this point
I have the same issue with my sitemap.xml how to solve the issue. i tried moving the sitemap.xml to a folder and tried but still same problem
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
I has a similar issue, when using generateSitemaps @CodingReaper1
The difference is that I had sitemap.ts here: src/app/sitemap.ts. And because of using
generateSitemaps()the sitemap was generated atwebsite.com/sitemap/0.xmlSolution was to move
sitemap.tsin an inner folder: That is:src/app/sitemaps/sitemap.tsAfter this google is able to fetch from
website.com/sitemaps/sitemap/0.xmlI think it’s worth trying to move your
sitemap.tsto./sitemaps/sitemap.ts, and try using the new URL location (i.e https://the-wild-oasis-admin-nextjs.vercel.app/sitemaps/sitemap.xml