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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则