I have a single distribution which serves 2 SPAs, the main app works but the path based app is not able to load the required assets when the index.html page loads.

Here is an example of the setup:

CloudFront Example

In summary:

  • 1 x Distribution with OAC enabled
  • 5 x behaviors, including the default(*)
  • 2 x origin response Lambda@Edge functions that check for 403 and 404 responses
  • 2 x S3 origins pointing to
  • 2 x S3 buckets with OAC enabled

The origin response functions handle redirecting when the bucket returns a 403. The only difference is the function for the bar behaviors uses the /bar/ prefix for its re-routing.

The main app loads fine and all the assets load, but when I try and load the /bar route it will load the /bar/index.html but then all the subsequent /bar/runtime.js files are not loading. The requests seem to be skipping the first 3 behaviors and triggering the default behavior and origin response function which then returns the main apps index content instead of the correct js file.

I originally had the following behavior paths:

  • /bar/index.html
  • /bar
  • index.html
  • *

and added the /bar/* path to see if this was required but it made no difference.

I seem unable to resolve this myself and would like to see if there is a problem with my setup or whether there is another issue that I am unaware of.

0

There are 0 best solutions below