Debugging Cloudfront with multiple origins (S3 + API Gateway) : path pattern not working.

1

I have set up a cloudfront instance with 2 origins (frontend and backend) for a relatively simple SPA app with a KOA backend. When either origin is set as the default (*) behavior, it works exactly as expected. Whenever I add a second origin (i.e. path pattern /v1/* ), it fails to recognize the pattern and instead tries to load the resource from the default (*) origin. I can flip back and forth by just changing which the default is pointing at, and that origin works fine, but the second path is never accessed.

The precedence is
0: /v1/* , APIGateway (origin path = "/Prod"

1: default(*) , S3

calling xxx.cloudfront.net/v1/test gives me a blank page from the react frontend (i.e. I see all the metadata, and the same as xxx.cloudfront.net/nonsense).

calling xxx.cloudfront.net/ launches the frontend, as expected.

calling xxx.execute-api.us-west-2.amazonaws.com/Prod/test gives me "Hello World"

Currently in the process of putting a bullet in it and running two cloudfronts (and all the CORS headaches that entails)

質問済み 2年前1283ビュー
1回答
0

I recommend you get in touch with AWS Support for help with this.

The only other suggestions I have for you are to ensure you have read the documentation: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html and/or to try out this CloudFront workshop: https://catalog.us-east-1.prod.workshops.aws/v2/workshops/9331108e-464e-4699-8a9c-486090105878/en-US/ to see if you can identify what might be wrong with your own distribution.

AWS
エキスパート
Paul_L
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ