2
votes

My api.<base-url> subdomain is not configured correctly. I purchased a domain through AWS and hooked it up to my static website running on Netlify. To do this, I set up Route53 to use Netlify's Name Servers. This works fine for the apex domain and https://<base-url> sends me to the static site.

Image of the Route53 hosted zone for this domain

I also have a node instance running on Heroku which I want to be hosted at api.<base-url>. Currently it is accessible by the heroku provided url (<project-name>.herokuapp.com)

I added a custom domain to Heroku for the api subdomain of my Netlify site api.<base-url>, the result of my heroku domains command is:

➜ heroku domains
=== <project-name> Heroku Domain
<project-name>.herokuapp.com

=== <project-name> Custom Domains
Domain Name   DNS Record Type DNS Target                                          
api.<base-url> CNAME           fitted-lemon-gzwby8exkguturnmh2emy5l4.herokudns.com

And I created a CNAME record on Route53 that points to this Heroku DNS target.

This sort of works, running host api.<base-url> gives:

➜ host api.<base-url>
api.<base-url> has address 104.248.60.43
api.<base-url> is an alias for <project-name>.herokuapp.com.
api.<base-url> is an alias for <project-name>.herokuapp.com.

So it is aliased to my heroku app, but when I go to api.<base-url> directly I get a white page that says 'Not Found', looks like this is on Netlify's side not Heroku? But I'm not sure. I feel like I need to tell Netlify somehow that there is a custom subdomain at api.<base-url> but the only thing I can find in the docs is setting up Netlify's subdomains from other branches of the project, not when a subdomain is hosted elsewhere.

Setting api<base-url> as a Netlify custom domain just ended up routing all the traffic for api.<base-url> to the static netlify site at <base-url> instead of my Heroku app.

I made a few other attempts but nothing has worked so far, I am officially stuck on this. Thank you in advance!

1
Were you able to get HTTPS working on both the client side (Netlify) and server side (Heroku)? I'm having trouble there, but I think it's HSTS-related. When I visit api.<base-url>, I get SSL_ERROR_INTERNAL_ERROR_ALERT.Paul Shryock

1 Answers

2
votes

Found it! Figures that it would click 30 minutes after posting.

I had a CNAME on Route53 but this was useless since I was using the Netlify DNS. You'll need to create a CNAME on Netlify that points to the host Heroku gives you.

So my heroku domains gave me the host I needed the CNAME to point to. I created a CNAME record on Netlify - which was not very obvious, I had to click into the badge 'Netlify DNS' in order to find the config.

I was able to create the right CNAME and then have it all work after that.