Problem: My live sitemap URL, https://www.remakeit.se/sitemap.xml
, is consistently serving incorrect plain text content, even though my build process successfully generates the correct XML content for this file.
Details & Evidence:
- Successful Deploy: My latest build completed successfully.
- Correct XML Generated (Proven by Log): My build command (
npm run build && node ./generate-sitemap.cjs
) includes a script to generate the sitemap. As shown in the deploy log linked above, I added debug logging. Between the markers--- Sitemap Content START ---
and--- Sitemap Content END ---
, the log clearly prints the correctly formatted XML content that the script generated in memory just before attempting to write it to the file. This XML includes proper<urlset>
,<url>
,<loc>
, and<xhtml:link hreflang="...">
tags for both ‘sv’ and ‘en’ languages. - Incorrect Deployed File Content: However, when I download the
sitemap.xml
file directly from the “Deploy file browser” section for the exact same successful deploy linked above, the downloaded file contains incorrect plain text data (listing only Swedish URLs without XML tags, and incorrect dates) – completely different from the XML content proven to be generated in the log. - Troubleshooting Performed:
- I have confirmed my
netlify.toml
file contains only standard SPA fallback rules and the correct build command, with no specific rules targeting/sitemap.xml
. - I have performed a “Clear cache and deploy site” action via the Netlify UI for the relevant deploy.
- I have tested the live URL
https://www.remakeit.se/sitemap.xml
in incognito/private browser windows and using mobile data (different network) – the incorrect plain text content is still served consistently. - I have confirmed the static file
public/sitemap.xml
has been removed from my repository.
Request:
Could you please investigate why the content of the deployed dist/sitemap.xml
file (as confirmed by downloading it) does not match the XML data that the build script successfully generated according to the deploy log?
It appears there might be an issue with how fs.writeFileSync
behaves in the build environment (failing silently after logging?), or an issue with how the sitemap.xml
file is being handled/served post-build by the Netlify platform or CDN for this specific path, overriding the correctly generated file content.
Please let me know if you need any further information, like the downloaded incorrect sitemap file.
Thank you for your help in resolving this strange issue.
Sincerely,
Marcus