The best way to add custom domains to your Glitch app is using Fastly, and it's free - follow the steps below.
Sign up for a free Fastly account
Sign up for a free Fastly developer account: fastly.com/signup
You'll get two things from Fastly:
- A service to deliver your Glitch website through the CDN
- A TLS certificate to safely send traffic to the domain through Fastly
Your Fastly service will automatically cache your Glitch site, making it faster and more reliable – it might even help you avoid hitting rate limits. The service will include security measures like DDoS protection out of the box. Once you send visitors through Fastly, you'll also be able to access observability metrics, letting you see what's happening with your website traffic.
Create a service
In your Fastly account, click Create service and choose CDN.
- Give your service a name of your choice – this is just so that you can identify it in your Fastly account.
- Enter your domain (it's easiest if you include the www – if you need to use an apex domain, like
suesmith.lol
instead ofwww.suesmith.lol
you'll find details in the Fastly docs, but you can alternatively redirect your apex domain to the www subdomain).
- Enter your origin – this is your Glitch website so it has a
.glitch.me
address – you can grab it from the Glitch preview. - Leave the recommended settings in their default state – make sure you keep the Override default host setting switched on as you need this for Glitch.
Activate your service!
Create a TLS certificate
Now you can grab a TLS certificate – Fastly gives you two for free. In the top menu in your Fastly account, click Security, then Manage certificates under TLS Management.
In TLS management, click Get started. If you have a TLS certificate in your account already you’ll click Secure another domain instead.
Enter your domain name and click Add.
Fastly will add your domain as the Common name. With Certainly selected, click Submit.
Verify your domain
When you submit your new TLS certificate, Fastly will provide the details to verify your domain.
Click Verification options.
This is where things can get a bit unpredictable depending on your domain registrar! The instructions below should work for most providers. 🤞
Copy the ACME DNS challenge CNAME and value (hit the clipboard icon for the value). The CNAME will be _acme-challenge
followed by your domain name, and the address to point the DNS record at will be a string of characters followed by fastly-validations.com
.
In your domain registrar account (wherever you registered the domain), navigate to the DNS settings. You’re going to add two new CNAME records, one to verify the domain for the TLS certificate, and one to route the domain traffic to Fastly.
First verify the domain:
- Set the host name to the address from the TLS info that’s something like
_acme-challenge
followed by your domain name (note that for some domain management tools you only need to enter the subdomain up towww
and they add the rest) - Set the address (sometimes called data, answer, or content, it’ll expect an IP address) to the value you copied that includes
fastly-validations.com
Save your new record. With any luck back in your Fastly account the domain will pass validation!
Shortly after this the certificate will be issued.
Point your domain at Fastly
Now you just need to point your domain to Fastly. This is what will happen once your domain settings are in place:
- Someone visits the domain
- The domain points at Fastly
- Fastly finds the service with the domain in it
- Fastly sends the visitor a response based on the service config – at first it’ll be the origin host response (your Glitch site), then later it might be cached, meaning Fastly doesn’t even need to visit the origin
First you’ll need to grab the correct CNAME to point your domain at – in your Fastly account, navigate to (Secure > TLS Certificates >) Domains and View details for the domain. Copy the CNAME record address – it will be a single character followed by .sni.global.fastly.net
.
Back in your domain registrar DNS settings, add another CNAME record, this time for the www
version of your domain, pointing at e.g. t.sni.global.fastly.net
(adjust that single character to match your certificate). If you already have a CNAME record for www
you'll need to replace it with the one for your Fastly service.
💡 If you have an existing CNAME record for the domain, you may want to reduce the TTL value before making a change, to speed up the process of sending your traffic through Fastly – this also helps if things go wrong and you need to make further changes.
Give it some time for your changes to propagate (at least the TTL value, which is in seconds) and you should see the origin site you pointed your Fastly service at when you visit the domain you registered!
🛠️ Use the terminal command dig <your-domain.com>
to check what’s happening with the DNS while you wait for changes to propagate.
For more detailed options check out the Fastly docs: Routing traffic to Fastly
FAQ
What happened to the "old way" of adding custom domains in the editor?
On March 1, 2023, Glitch creators reported that SSL certificates of newly added domains were not working (ie. https was not working). The third-party app we were using to provide this feature has been turned off to prevent new additions and will remain so indefinitely. We're calling existing domains that were added this way "legacy custom domains"
What will happen to to my legacy custom domains that were added the "old way"?
- Users who have already added a custom domain in the past will still be able to use their custom domains, as this incident only impacted the new creation of SSL certificates.
- If you remove your existing legacy custom domains in the editor, they cannot be re-added the "old way", but you can add them via Fastly by following the steps above.