Custom Domains for Pages (saas for custom domains)

Need some guidance with Pages custom domains . I would to offer my saas customers the ability to add their custom domains within the dashboard on certain routes like "/dashboard" So i set up a under pages - > custom domains > add a domain i.e. custom.mycustomer.com which points to my pages.dev And my customer adds a dns CNAME setting of custom to pages.dev This all works! But it works for all routes, we need only custom domains on /dashboard. Do i need to do something else what are my options?
2 Replies
Chaika
Chaika15mo ago
Your SaaS customers have their own domains that you would want to use with this, I assume? The way DNS works is off hostnames, it looks up for example customer.mycustomer.com, with web servers you have A/AAAA (or CNAME records which resolve into A/AAAA) records and web browsers look that up, and send the request to the found IPs. Path is not part of that, not part of DNS. Some of Cloudflare's features can work off path like that, for example Worker Routes, because the traffic all goes through Cloudflare, and they can check if it matches one of the Worker Routes, if not, proceed on. With that same idea in mind, if all of your customers were using Cloudflare, you would create a proxy worker which they add on example.com/dashboard/* path, and proxy traffic to your pages.dev/a custom domain of your pages.dev. It would cost them worker invocations for each request though. Orrr.. you could just have them use a subdomain like dashboard.mycustomer.com and not vary on paths
Ricky U
Ricky UOP15mo ago
@Chaika Yes, to clarify, my customer would like to use a subdomain from their apex, i.e. files.widgetstore.com (lets assume they are not using cf) So they add a CNAME for files and point it to my pages.dev domain . So far so good. I then add a custom domain in my pages project called files.widgetstore.com and thats great. Now i am not sure which service to use on my end in cf dashboard. to make sure the paths are all correctly servced. i..e when a user goes to files.widgetstore.com they see my entire frontend site mycompany.com , not what i want. I only want the custom domain to work when it is within a suffix path like /dashboard , otherwise it should route back to my apex domain (mycompany.com) so to make my example hopefully clearer: 1st step (completed) customerA has set up subdomain of files.customerA.com -> routes to my pages.dev, but since their isn't a valid path /dashboard it will be redirected back to my pages.dev (mycompany.com) 2nd step (not sure if to use page rules, or bulk redirects or another cf service) if CustomerA vists files.customerA.com/dashboard/some params -> this route is ok and cf maps it to pages.dev (keeping the customerA domain in the url intact) We then proceed to check the cookies to see if their are authrozied and proceed to the dashboar otherwise redirect back to mycompany.com I have completed hte first part, but not sure how to do step b.. If possible i would like to avoid invoking a worker, and rather use a page rule,but don't mind either.
Want results from more Discord servers?
Add your server