Workers w/ custom domains

Has anyone been able to get multiple brands (i.e. main, staging) to work with static, custom domains? When I setup different subdomains, they both get applied to the same branch even with the branch qualifier in the CNAME.
26 Replies
Chaika
Chaika8mo ago
Are you talking about Pages w/ Branches? Workers used to support a similar kind of thing with Environments but it got dropped a long time ago
gcaprio
gcaprioOP8mo ago
Ah, hmm. no, this is a react app using workers looks like there's a preview & production build, so I can't have static domains for those?
Chaika
Chaika8mo ago
That is Cloudflare Pages they're under the same section so it might be kind of confusing the answer is yes though, you can point to specific branches: https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/ as long as you are using Cloudflare DNS for your domain
gcaprio
gcaprioOP8mo ago
yeah that's what I've tried, but doesn't seem to work.
Chaika
Chaika8mo ago
what are you trying to point at? It needs to be an actual branch, not just preview for example (unless your branch was called preview)
gcaprio
gcaprioOP8mo ago
yeah, we have two, main and staging and trying to setup the cname as main.<worker name>.pages.dev and staging.<worker name>.pages.dev but both always end up under the Production deployment, under Domains: ...
Chaika
Chaika8mo ago
You're using Cloudflare DNS right, and the CNAME it creates is proxied?
gcaprio
gcaprioOP8mo ago
yes and yes
Chaika
Chaika8mo ago
What do you mean "under the production deployment under domains"? None of the Pages UI will change if you use that setup, it should simply just serve the latest staging build
Chaika
Chaika8mo ago
oh I think I see what you mean, you're talking about this?
No description
gcaprio
gcaprioOP8mo ago
yeah exactly
Chaika
Chaika8mo ago
yea that won't update or anything it should just simply work though
gcaprio
gcaprioOP8mo ago
that's what I thought, but sadly nope. I can tell because the ENV VARs are setup differently but I get the same values regardless of which domain I use.
Chaika
Chaika8mo ago
and it works/shows fine if you go directly to staging.pagesProject.pages.dev?
gcaprio
gcaprioOP8mo ago
haven't tried that, was always either using the domain setup or the URL with the dynamic value let me see yup, that works. maybe I'll give the domains anothe shot.
Chaika
Chaika8mo ago
yea, if they don't work please share the cname you end up with and the custom domain where the staging branch should be served at
gcaprio
gcaprioOP8mo ago
hmm, i spoke too soon wasn't actually working, might have been just cached. so even when I use main.project.pages.dev it points to the staging deployment as soon as I switch back to the <hash>.project.pages.dev for main it works fine
Chaika
Chaika8mo ago
you don't get aliases for production deployments, so if you ever had a preview deployment on the main branch I'd imagine that is where that came from If you click on view details of a preview staging deployment, it should tell you the alias for it
gcaprio
gcaprioOP8mo ago
ok so staging.project.pages.dev points to Preview / staging and project.pages.dev points to Production / main that correct?
Chaika
Chaika8mo ago
<branchname>.project.pages.dev points to the latest preview deployment on that branch
gcaprio
gcaprioOP8mo ago
yeah, actually the preview ones were always correct, it was the production one that was the issue. so is project.pages.dev always pointing to latest product deployment then?
Chaika
Chaika8mo ago
yes
gcaprio
gcaprioOP8mo ago
hmm, ok. I'll try and reset things and try again thank you for your help @Chaika
kingmesal
kingmesal8mo ago
quick sanity check here... In all my workers I use this format for my wrangler.toml
[env.production]
kv_namespaces = [
{ binding = "KV_STORE", id = "zxy" },
]
[env.production]
kv_namespaces = [
{ binding = "KV_STORE", id = "zxy" },
]
is that format supposed to be able to work in the new wrangler pages deploy capability ? Maybe something was wonky with pages deployments yesterday, but I tried deploying like 7+ times and each time it sat "queuing" and never loaded ... a few hours later it started working, after I removed all those that were queuing On this topic of the new wrangler pages deploy I used to set a variable that was a deploy time value and I would use --var key:value is this going to be coming back to the deploy function soon?
Chaika
Chaika8mo ago
This is a post in the general-help forum for a specific user about Pages Custom Domain branches. If you need help, please make your own thread. There is also a specific forum for pages issues #pages-help
kingmesal
kingmesal8mo ago
OMG, thanks. I had been viewing the wrangler channel and I searched and didn't realize it jumped me elsewhere
Want results from more Discord servers?
Add your server