Background
We would like to have a CloudFront act as a router in front of our AWS Amplify SPA. The reason for this is that we need to share a common domain across all of our SPAs so we can share localStorage. Thus each SPA will be hosted at a sub-path on the CloudFront. The reason we are using Amplify is because we are using a client side routing, so we need to redirect requests from https://spaOne-amplify.com/spaOne/pages/somePage to the index.html
The basic idea is that we will have a CloudFront that proxies/caches all requests from https://cloudFrontDomain.com/spaOne/* to https://spaOne-amplify.com/spaOne/*.
Problem
However, for some reason when a SPA hosted by Amplify receives a Via header that looks like it came from a CloudFront, it goes into a redirect loop.
GEThttps://spaOne-amplify.com/spaOne301- /someRandomId/GEThttps://spaOne-amplify.com/someRandomId301- /someRandomId/- ... and so on and so forth
I can't find any mention of this behaviour detailed anywhere, and I'm at a loss for how to avoid it. If I remove the Via header, or change it, the behaviour stops.
The following causes a redirect loop:
Via:1.1 7331c3ff7c4cd86239addbfddaa5cee4.cloudfront.net (CloudFront)Via:1.1 abc.cloudfront.net (CloudFront)
But these do not:
Via:1.1 7331c3ff7c4cd86239addbfddaa5cee4.cloudfront.netVia:1.1 spaOne-amplify.com (CloudFront)