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
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
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?
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
yeah that's what I've tried, but doesn't seem to work.
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)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: ...
You're using Cloudflare DNS right, and the CNAME it creates is proxied?
yes and yes
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
oh I think I see what you mean, you're talking about this?
yeah exactly
yea that won't update or anything
it should just simply work though
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.
and it works/shows fine if you go directly to staging.pagesProject.pages.dev?
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.
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
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 fineyou 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
ok so staging.project.pages.dev points to Preview /
staging
and project.pages.dev points to Production / main
that correct?<branchname>.project.pages.dev points to the latest preview deployment on that branch
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?
yes
hmm, ok. I'll try and reset things and try again
thank you for your help @Chaika
quick sanity check here...
In all my workers I use this format for my wrangler.toml
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?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
OMG, thanks. I had been viewing the wrangler channel and I searched and didn't realize it jumped me elsewhere