How to Spot and Fix Soft-404 /sitemap.xml Bugs on React, Vite, Cloudflare & Next.js Sites

Published by FoundInAnswers • Reviewed by Rob Pfleghardt • 4 Verified References

Direct Answer: A Soft-404 /sitemap.xml bug occurs on React, Vite, Cloudflare Pages, Vercel, and Netlify single-page apps when a catch-all SPA fallback rule (* -> /index.html 200) serves homepage HTML instead of valid application/xml. In our 30-domain SaaS crawl, 37% had missing or broken sitemaps. Fix it by placing static XML files in public/ or excluding /sitemap.xml and /llms.txt before your SPA catch-all rewrite.

Hosting / Framework StackWhy the Soft-404 HappensSymptom in Google Search ConsoleExact 2-Minute Fix
Vite / React on Cloudflare PagesSPA fallback serves index.html when sitemap.xml is missing from dist/"Sitemap could not be read: Sitemap is HTML"Put sitemap.xml in public/ (or functions/sitemap.xml.js + _routes.json)
Vercel SPA with vercel.json rewritesRegex "(.*)" -> "/index.html" intercepts /sitemap.xml & /llms.txtHTTP 200 text/html returned to GooglebotExclude .(xml|txt|json) in source regex or use filesystem handle first
Netlify SPA with _redirects/* /index.html 200 placed above static/proxy rules without file presentCrawlers parse <!DOCTYPE html> and abortPut explicit /sitemap.xml & /llms.txt 200 rules ABOVE /* /index.html 200
Next.js App Router (app/sitemap.ts)Middleware matcher intercepts /sitemap.xml with auth or locale redirect"Couldn’t fetch" or 307 redirect loopExclude sitemap.xml, robots.txt & llms.txt from middleware.ts matcher

1. Why Browsers Hide SPA Soft-404 Traps From Founders During Manual Testing

Single-page application routing is designed so client-side URLs like /pricing or /dashboard render smoothly when refreshed in a browser: the server returns HTTP 200 with index.html, and React Router takes over. Unfortunately, that exact convenience creates a silent SEO disaster whenever /sitemap.xml, /robots.txt, or /llms.txt is missing or intercepted by a broad rewrite rule.

If you type https://yourdomain.com/sitemap.xml into Chrome on a misconfigured SPA, you do not see an ugly 404 error page; you see your homepage render normally with HTTP 200! Many founders assume everything is working until months pass with zero organic impressions and Google Search Console displays a red "Sitemap is HTML" error.

Always test machine endpoints with curl -i rather than a visual browser tab: if the Content-Type header says text/html or the first 15 bytes begin with <!doctype html>, every search and AI crawler is treating your sitemap as broken.

2. Stack-by-Stack Root Causes Across Cloudflare Pages, Vercel, Netlify & Next.js

Although the symptom is identical (HTTP 200 HTML instead of XML), the routing layer responsible differs slightly across modern edge hosts.

Match your deployment stack in the matrix below to pinpoint which config file is intercepting your XML and plain-text discovery endpoints.

3. Copy-Paste Routing Fixes for Cloudflare Pages, Netlify, Vercel & Next.js Middleware

On Cloudflare Pages and Netlify, _redirects rules evaluate top-to-bottom on the first match (after checking static files in dist/ unless forced). Always place explicit /sitemap.xml, /llms.txt, and /robots.txt rules above any catch-all /* /index.html 200 fallback.

On Next.js App Router, check middleware.ts: default Clerk, NextAuth, or i18n matchers frequently intercept /sitemap.xml and /llms.txt unless you exclude them explicitly in config.matcher.

Cloudflare/Netlify _redirects + Next.js middleware.ts Safe Exclusions
# 1. public/_redirects (Cloudflare Pages / Netlify: explicit files BEFORE SPA fallback)
/llms.txt     https://foundinanswers.com/bridge/your-slug/llms.txt     200
/sitemap.xml  https://foundinanswers.com/bridge/your-slug/sitemap.xml  200
/robots.txt   https://foundinanswers.com/bridge/your-slug/robots.txt   200
/guides/*     https://foundinanswers.com/guides/your-slug/:splat       200
/*            /index.html                                              200

// 2. middleware.ts (Next.js App Router: never run auth/locale redirects on SEO files)
export const config = {
  matcher: [
    '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|llms.txt).*)',
  ],
};

4. Second Sitemap Mistake: Including Queued 404 URLs or Non-Canonical Redirects

Fixing Content-Type: application/xml is half the battle; the URLs listed inside <loc> tags must also pass strict hygiene. Google Search Console demotes sitemap trust if <loc> entries return HTTP 404 (such as upcoming scheduled blog posts that have not published yet), HTTP 301 redirects (such as http://, www vs. non-www mismatches, or trailing slashes that redirect), or pages carrying noindex.

Ensure every <loc> URL in /sitemap.xml returns a direct, single-hop HTTP 200 OK and matches the exact <link rel="canonical"> tag rendered in that page’s <head>.

5. Terminal Verification Commands Before Resubmitting in Search Console

Run curl -sI https://yourdomain.com/sitemap.xml and verify HTTP/2 200 alongside content-type: application/xml; charset=utf-8. Next, pipe the body through head -n 5 to confirm <?xml version="1.0" encoding="UTF-8"?> appears on line 1.

Once verified, resubmit https://yourdomain.com/sitemap.xml inside both Google Search Console -> Sitemaps and Bing Webmaster Tools -> Sitemaps so both engines clear cached Soft-404 flags within 24 to 48 hours.

Verified Primary Sources & Reference Citations

Frequently Asked Questions

Why does Google Search Console say "Sitemap is HTML" when my file ends in .xml?

Google ignores the .xml filename extension if the response body starts with <!DOCTYPE html> or <html>. That almost always means your file was not copied into your production build output folder (dist/ or out/), causing your SPA router to serve index.html at /sitemap.xml.

Should /sitemap.xml include hash anchor links like /#pricing or /#features?

Never include #hash fragments in /sitemap.xml. Search crawlers strip URL fragments and treat https://yourdomain.com/#pricing as a duplicate of https://yourdomain.com/. Only list distinct, server-addressable canonical paths.

Do small websites with 10 to 30 pages really need an XML sitemap?

Yes, especially when launching new Topic Hubs on a young domain with few external backlinks. Submitting an accurate XML sitemap with real <lastmod> dates tells Googlebot and Bingbot the exact day new guides go live rather than waiting weeks for random recrawls.

Does <priority> or <changefreq> vs. <lastmod> matter more in sitemap.xml?

Google officially ignores <priority> and <changefreq> while actively using accurate <lastmod> timestamps (when they reflect real content creation or substantive updates rather than changing every URL’s date on every build).

How can I test if my site has a Soft-404 bug without opening a terminal?

Paste your domain into foundinanswers.com/tools/ai-crawler-checker or /tools/llms-txt-checker. Both tools inspect raw HTTP status codes, Content-Type headers, and HTML signatures on /sitemap.xml, /robots.txt, and /llms.txt in three seconds.

Hub 4: Fixing Soft-404 Sitemaps, Bing IndexNow & JSON-LD Schema

Eliminating single-page app (SPA) indexing bugs where /sitemap.xml and /llms.txt accidentally return homepage HTML.