jinty / prerender-cloudfront

prerender.io cloudfront example middleware
MIT License
128 stars 51 forks source link

This solution will not work with Amplify for Next.js using SSR #25

Open wyckojr opened 2 years ago

wyckojr commented 2 years ago

After a lengthy conversation with AWS support, they came to the conclusion that you cannot have a CloudFront distribution in front of an Amplify App that also uses a CLoudFront distribution. This is true for Apps that are running Next.js with SSR, as we are.

AWS confirms that presently there is no solution to utilize prerender.io with Amplify in this fashion. From AWS support: Hello,

I did have a discussion on this with the Amplify Console team, and they confirmed that conclusion.

From AWS:

Support for prerender.io is currently not possible via an Amplify hosted SPA . There are 2 reasons for this (based on the CloudFront example from the GitHub ticket):

We don't associate any ViewerRequest Lambda@Edge with the managed CloudFront distribution, so we won't be able to add new headers based on the user-agent, query_string etc. before the request reaches the CDN. Even if we were to workaround that by handling everything beyond the CDN (The customer would still have to work with a 2 second TTL), we don't have a way to achieve a redirect to any prerender.io server since our OriginRequest Lambda@Edge implementation does not support this customization.

Now support for this may be added in the future as it has been something that has been requested by previously as well. Periodically check the release history on the Amplify Console GitHub page for the latest supported features [1].

Please reach out if you have any further questions.

References: [1] https://github.com/aws-amplify/amplify-console

We value your feedback. Please share your experience by rating this correspondence using the AWS Support Center link at the end of this correspondence. Each correspondence can also be rated by selecting the stars in top right corner of each correspondence within the AWS Support Center.

Best regards, Daniel S. Amazon Web Services