Worker doesn't work on a netlify hosted site

Hey guys,

We just moved our DNS to Cloudflare in order to be able to use the Cloudflare workers. The problem is that our build pipelines are heavily based on the netlify features, and therefore we can’t move our CDN over to the Cloudflare too.

So after enabling our DNS and setting some CNAME records, I found out that workers would not work when the Cloudflare is on the DNS only mode ( is turned off)

But in order for netlify to work correctly with Cloudflare, it’s necessary to turn off this option. Can you guys think of any way that I can bypass this problem?

Also, another problem is that after turning the DNS only option off and on, the workers don’t work at all, even with the orange cloud turned on.

First of all, Workers only works on :orange: hostnames, as that’s what it takes to route requests through Cloudflare. If you set the hostname to :grey:, you’re really not using Cloudflare. Just DNS. Switching between :grey: and :orange: takes five minutes to switch over.

If you could figure out why Netlify isn’t working with Cloudflare, that would really help, but you can start by creating a Page Rule to match* and add all the settings you can to bypass and disable as much as possible.

Hi @sdayman, Thank you for your response.
I just found out I was in the five minute period you mentioned, now everything is working but netlify (in it’s dashboard) says that I should re-check my dns settings.
But now I’m a little concerned that we may lose every performance improvement we gained by moving to SSGs and DNSs, by adding another hop to every request every user makes (request first reaches to the Cloudflare worker servers, and then another request initiates towards the netlify servers, where our resources are)
Am I right about this? and how much negative effect do you think it will have?

I don’t expect you’ll notice any overhead. Here’s the result of a curl -I (headers only) command to my test site’s wp-admin. It hits a Worker that modifies my CSP headers for that directory.

dnslookup: 0.001633 | connect: 0.001893 | appconnect: 0.186796 | pretransfer: 0.186870 | starttransfer: 0.560214 | total: 0.560336 | size: 0

If I bypass Cloudflare, the same curl command gets me this.
dnslookup: 0.001741 | connect: 0.002083 | appconnect: 0.084767 | pretransfer: 0.084877 | starttransfer: 0.424048 | total: 0.424136 | size: 0

Typically, the efficiency Cloudflare offers outweighs the extra time added for requests that actually hit your server.