Routing to REST API on ElasticBeanstalk through CloudFront

Viewed 117

We have this setup where

  • Express API running on Elastic Beanstalk environment behind an ALB.
  • S3 bucket for static content.
  • CloudFront as an access point for everything.

For some reason, CloudFront simply refuses to return a response from the API.

PathPatterns are configured like this:

Screenshot

where APIOrigin is pointing to the the ALB in front of the Beanstalk environment.

The only thing the I'm getting from the endpoint xxxx.cloudfront.net/api/health is this: Sorry, cannot embed images yet

Yet calling the addess {loadbalancerUrl}/health returns the correct response.

The xxx.cloudfront/api response contains headers

Access-Control-Allow-Origin

Access-Control-Allow-Headers

Access-Control-Allow-Methods

exactly like the Express API on Beanstalk sets them, so some communication exists there, but no response. (JSON response is expected)

We are avoiding using API Gateway for company reasons.

What can I try next?

0 Answers
Related