/sitemap.xml is returning a 404

I have deployed my site through netlify and everything seems to be working as expected except for the sitemap. The site is build using Vite.

I have added a sitemap.xml file and a robots.txt file to the root directory. My netlify.toml file in the root directory looks like this:

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "/sitemap.xml"
  to = "/sitemap.xml"
  status = 200

[[redirects]]
  from = "/robots.txt"
  to = "/robots.txt"
  status = 200

and my _redirects file looks like this:

/robots.txt    /robots.txt   200
/sitemap.xml    /sitemap.xml   200
/*    /index.html    200

The netlify site is santabarbaramyo. When I test the /sitemap.xml file locally it works as expected. However when I try to access www.santabarbarmyo.com/sitemap.xml in production after deployment via netlify, I get a 404 not found error.

I have tried using the netlify sitemap plugin, however that only returns the home page since this is a single page react site. I need to be able to use my sitemap.xml file so that all pages are indexed by google. Any help you can provide would be appreciated!

Why not use the public directory that Vite provides?

1 Like

And that fixed it. Thanks!