xmlaws-amplifysitemap

sitemap.xml not showing up in production


I am building a Typescript and React app and I am trying to add a sitemap.xml to my site. When I go to the /sitemap.xml endpoint when running on localhost, it returns the sitemap. But when I push to production on AWS Amplify and I go to the endpoint (https://wordle.latindictionary.io/sitemap.xml), it returns the homepage.

I have the sitemap.xml in my public directory, here is a link to a screenshot of the file structure: https://i.sstatic.net/hh0Fb.png

Here is my XML file: https://i.sstatic.net/MWNCw.png

As I mentioned earlier, I am hosting the site via AWS Amplify and even when I run the production build on localhost it still returns the sitemap. Also, if you go to this endpoint https://wordle.latindictionary.io/favicon.ico it returns the favicon. So I am not sure why images and other items in the public folder would be returned and not the sitemap.xml.

Hopefully, there is an easy fix to this and not something wrong with Amplify.

Thanks, Theo


Solution

  • I finally figured it out. My solution was to change the redirect settings in AWS Amplify to allow file types ending in .xml to be returned and not forwarded to the root URL (/).

    This means adding adding xml to this rule </^[^.]+$|\.(?!(xml|css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>.