1

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

enter image description here

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.

1
  • Solved it by generating middleware for routing at build time, ensuring Amplify handles it correctly. Added necessary rewrites in amplify.yml. Commented Mar 12 at 4:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.