Pages to Workers

probabaly, but there isnt a guide on how to move an entire app in to a worker, and then is it server side rendered in this case? it should still be client side.
26 Replies
Hello, I’m Allie!
Threading to clean up Moving here to not clutter for others
Hard@Work
Hard@Work2mo ago
Sorry for the reping @Ricky U, but if the build output is entirely static, moving to Workers Assets should be something like this:
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-worker",
"compatibility_date": "2025-09-25",
"assets": {
"directory": "./<OUT_DIR>/"
}
}
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-worker",
"compatibility_date": "2025-09-25",
"assets": {
"directory": "./<OUT_DIR>/"
}
}
With the same build command that you already have This won't do the Metatag thing you were talking about, but this was just to get you started
Ricky U
Ricky UOP2mo ago
Okay great, thanks for setting up this thread, i can post back the results here.
Hard@Work
Hard@Work2mo ago
Try it in wrangler dev. Though, I wouldn't deploy it yet, since it doesn't have the rewriter yet
Ricky U
Ricky UOP2mo ago
Thanks again for your help earlier. I just wanted to clarify one point from our discussion because I’m a little unsure: - On Cloudflare Pages, I was given 250 custom hostnames (extended to 500 during my transition). - For Workers, is there a similar allowance for vanity/custom hostnames, or are they billed differently? Specifically, if I attach 300+ vanity domains (e.g. docs.customer.com) to a Worker, would those count as Custom Hostnames under Cloudflare for SaaS (and therefore be billable after a certain threshold), or are they treated differently from Pages’ model? I may have misunderstood somewhere that Workers could handle unlimited vanity domains if I managed the routing myself, so I’d like to confirm the actual limits and whether there are charges once I go beyond 100/250. Will my function wrangler.toml be like this:
routes =
pattern = "docs.customer.com", zone_id="adf3eacd5197c2aa23dcc101b83dfxxx"},
{ pattern = "files.client.net, zone_id="adf3eacd5197c2aa23dcc101b83dfxxx"},
]
routes =
pattern = "docs.customer.com", zone_id="adf3eacd5197c2aa23dcc101b83dfxxx"},
{ pattern = "files.client.net, zone_id="adf3eacd5197c2aa23dcc101b83dfxxx"},
]
` wont the zoneid be the same as thats my Sinosend.com zone id. im trying to transtion from pages where i am using custom hostnames to workers, but still strugging with how to setup my 250 vanity domains here sorry for pinging you @Hard@Work whenever you have time thanks
Hard@Work
Hard@Work2mo ago
To confirm, are all these vanity domains on your account?
Ricky U
Ricky UOP2mo ago
the vanity domains are my customers, they have already cnamed to my pages domain, and i have used the api to add them to pages custom hostnames, it works beautifully.. so no i dont own these custom domains. -- now transitioning everything over to workers, but dont want to have to ask my customers to well... change their dns again. @Hard@Work tks
Hard@Work
Hard@Work2mo ago
If they aren't on your account, you would need to use CF for SaaS, which means they would at minimum need to change their CNAME to point to your domain isntead of <whatever>.pages.dev
Ricky U
Ricky UOP2mo ago
oh how sad but thanks. :(. this means i need to keep pages going.. Also cf for saas pro plan offers only 100 customs domains, vs pages pro is 250.. so in this case pages has a better feature set. lol. @Hard@Work the force of dns change is going to be an issue, i wonder if i can do anything like add a pages function which proxies to the worker.. dont know. sorry to nudge @Hard@Work hoping there is another solution where i dont have to force users to change their dns in order to have a better transition.
Hello, I’m Allie!
I forget, what was the original reasoning for wanting to use Workers?
Ricky U
Ricky UOP2mo ago
slowly transitioning away from pages functions to workers and continue to support my custom domains that i had set up (300 now) .. you mentioned i need to use cf for saas, but the problems are all my users need to now change their cname , and cf for saas only has 100 domains included, vs pro pages support 250
Hello, I’m Allie!
Just looked at the history, looks like it was because you wanted new stuff that isn’t accessible in Pages, like sockets etc. In that case, you can probably use a Pages function to redirect to the Worker, though you would be billed twice
Ricky U
Ricky UOP2mo ago
oh correct, like mongodb driver that only works in workers due to the wrangler version that was the main reason
Hello, I’m Allie!
If it really is a dealbreaker, I would set up the function that calls the Worker, but also have new customers sign up via CF for SaaS
Ricky U
Ricky UOP2mo ago
yes new customers sign up for cf for saas... is there a upper limit per domain or its unlimited? 0.10/cens per domain lifetime? also if i move over to workers, and am on the paid worker plan, do i then give up my pro pages plan?
Hello, I’m Allie!
I mean, your Pages plan is derived from the highest plan on any zone you own, so you wouldn’t need to give it up I believe pricing is 10¢ / domain / month
Ricky U
Ricky UOP2mo ago
Hi @Hard@Work Ive adding a test custom domain to SSL for saas, here is how I set it up and my problems - added clients domain 'files2.pmgrouphk.com' to cloudflare for saas and got a green "Active"
No description
Ricky U
Ricky UOP2mo ago
They added both the Txt records and CNAME records to my cname domain which i created called "customers.sinosend.com"
Ricky U
Ricky UOP2mo ago
i create two A records in my zone pointing to 192.0.2.1 customers and proxy-fallback
No description
Ricky U
Ricky UOP2mo ago
then in my worker routes i want to execute the worker only on a test route for now so any /rtest/* should trigger the worker.
No description
Ricky U
Ricky UOP2mo ago
This is the result: sinosend.com/rtest/DmLiIfGGG <- works, easy this is my domain customers.sinosend.com/rtest/DmLiIfGGG <- works, this is my A records i created the problem now is my customers domain files2.pmgrouphk.com/rtest/DmLiIfGGG <-- is very very slow. it works, but its painfully slow to respond. there is no error im sure its something obvious
Hard@Work
Hard@Work2mo ago
Does your Worker make a call to something else?
Ricky U
Ricky UOP2mo ago
@Hard@Work The worker calls the DB, bt its pretty quick with connection pooling from all other workers including the one on my domain, for some reason only for custom hostnames like this one its very slow.. Something interesting is tha the assets css/js/etc is very slow to responsed ( see the dev tools screenshot) They remian pending for 5 seconds then show a 522
No description
Ricky U
Ricky UOP2mo ago
but the page itself returns 200 immd. The same worker on my apex domain sinosend.com/rtest/DmLiIfGGG works very quick... so its something with the 522 error code that is blocking assets from being loaded in time. @Hard@Work is the way I set up everything correct? not sure why some assets are getting 522, while the main site gets 200, this is very strange indeed.
Hard@Work
Hard@Work2mo ago
To be honest, I'm not entirely sure. Maybe try creating a new thread in #workers-and-pages-help with just this issue?
Ricky U
Ricky UOP2mo ago
ive reverted to continue to use pages function and call another serverless function (lambda) to connect to my db... Since Pages workers dont suppprt monogdb... so guess im taking a step back, but it works.

Did you find this page helpful?