I'm trying to set up a Web Application hosted on Heroku. DNS routing is done through AWS Route53 and distribution through CloudFront. I have purchased my own SSL cert for, let's say, www.example.com.
It's all working except that I want to be able to use subdomains and then show a different app within Heroku. This also works locally. However, if I whitelist the host headers in CloudFront so that I can do this routing, Heroku will redirect to an unknown application.
AWS says it's a misconfiguration on Heroku's end and Heroku states that I have misconfigured the DNS routing and need to apply the generated CNAME to Route53. But that CNAME routes to CloudFront.
So the setup right now is:
Heroku
Hosting Web App. Automatic Certificate Management is enabled. No domain added.
Route53
CNAME points to CloudFront dist. As well as A and AAAA. Also for * wildcard
CloudFront
Origin points to Heroku deployment. Has CNAMES for the custom domain URLs like *.example.com
My own custom SSL with * wildcard support was uploaded to AWS CM and added to CloudFront. It works, but I can imagine I've misconfigured this at some step.
How come if I send a host header that my Heroku deploy redirects to the wrong app?