Worker on existing website
I have an existing website at www.example.com hosted outside cloudflare and I need a worker to respond to 2 endpoints at www.example.com/foo and /bar
Is that possible and where might I find docs specific to it?
6 Replies
you'd need the DNS to resolve to Cloudflare
or you'd need to do a hacky thing at origin where it then invokes Workers but that kinda ruines the point haha
The DNS does currently resolve to Cloudflare but using the CNAME method since Cloudflare is not our primary DNS server (yet we are working on moving it over)
So if I'm using a Nuxt project and I deploy that using Wrangler. Normally I'd set a custom domain, but would that then takeover the entire domain using that method? Or would it know only the routes for the Nuxt project?
I do see the
Workers Routes
page under the domain so I assume I'd manage it that way and not specify a custom domain?correct yeah, routes is what you're looking for, you can setup
www.example.com/foo*
to handle only requests starting with /fooAwesome!
Also, could I intercept ALL 500 errors on all sites and modify the response from my worker?
You can't match on status code with Workers but this sounds ideal for: https://developers.cloudflare.com/rules/custom-error-responses
Is that visible in the web ui or just an api level feature?
Ah I see I can set a url for 500 Class Errors under Custom Pages