Skip to content

Amplify next.js multi-zone setup w/ assetPrefix

0

Next.js multi-zone setup docs: https://nextjs.org/docs/app/guides/multi-zones

There's an issue where adding an assetPrefix (f.ex. /zone-b) results in Amplify omitting the static folder from the build artifacts, thus resulting in a 500 error as files are missing from deployment.

Any insights why this happens ? (does amplify assumes the static files will be hosted elsewhere, therefore it skips including them in the artifacts ?) Any short-term work-arounds ?

related github issues : https://github.com/aws-amplify/amplify-hosting/issues/3619 https://github.com/aws-amplify/amplify-hosting/issues/3965

asked a year ago202 views

1 Answer
1

When deploying a Next.js application with a multi-zone setup using assetPrefix on AWS Amplify, you're encountering an issue where the static folder is being omitted from the build artifacts, resulting in 500 errors due to missing files.

This appears to be a known issue with AWS Amplify's handling of Next.js applications that use assetPrefix. Based on the information available, when you specify an assetPrefix (like "/zone-b"), Amplify may be incorrectly interpreting this configuration and not properly including the static assets in the deployment artifacts.

For a short-term workaround, you might try:

  1. Modifying your amplify.yml configuration to explicitly include the static files in the artifacts section
  2. Adjusting your build process to ensure the static files are copied to the expected location
  3. Opening a support case with AWS under "Account and billing" (which can be done free of charge) to get specific assistance with this issue

Since this appears to be a known issue based on the GitHub issues you referenced, the AWS Amplify team may be working on a fix. In the meantime, reaching out to AWS Support could provide you with a more tailored workaround for your specific setup.
Sources
Unable to deploy Next JS app on Amplify (Please reach out to your support representative.) | AWS re:Post
Deploy React and Server Side Rendered Apps and Static Sites - Amplify Hosting - AWS

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.