I have a Next.js application where:
Staging is hosted on Vercel (everything works fine). Production is hosted on AWS Amplify. When I check the sitemap in Vercel, it returns the expected results:
https://vercel.domain.ai/sitemap.xml ✅ Works
However, in Amplify, it returns a 404 error:
https://amplify.domain.ai/sitemap.xml ❌ 404 Not Found
My Current Setup Next.js version: latest Amplify build settings (amplify.yml):
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
redirects:
- source: '/api/<*>'
target: '/api/<*>'
status: 200
Sitemap Generation: The sitemap is dynamically generated using getServerSideProps() in a file called pages/sitemap.xml.js. It works fine in development and on Vercel.
