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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠