This Cloudflare worker with HonoJS is used as a fallback for proxied domains with Cloudflare SSL/TLS for SaaS.
This is an example of how to add custom domains for your customers to your SaaS service.
To use Cloudflare for SaaS, follow these steps:
- Enable Cloudflare for SaaS in the zone settings
- Create a proxied dummy DNS record, like:
AAAA -> dns.example-saas.com -> 100::
- Create a CNAME record from the customer domain to the dummy record, like:
CNAME -> test.example-customer.com -> dns.example-saas.com
- Create a SSL Certificate for the customer domain in the SSL/TLS -> Custom Hostenames section, and verify it with the given TXT records
- Add a fallback origin (the domain which is used as the default origin for custom hostnames)
- Add Worker routes in the Worker Routes section (Zone settings, not Worker settings) so the Zone is not completely occupied by the worker:
example-saas.com/*
-> None (Services are disabled on this route)*.example-saas.com/*
-> None (Services are disabled on this route)*/*
-> Worker
That's it! 🎉
It uses the above shown principle and displays the domain and other info about the request when accessed.