522 on custom domain for worker

I created a worker that is fully operational on the dev environment. It is essentially a reverse proxy that changes some stuff in the body that comes back from the origin, before passing it back to the browser.

Situation:

  • The worker works on the dev environment flawlessly.
  • I added a custom domain to the worker, using the new “custom domain” feature (technically it is a subdomain).
  • I host the domain on Cloudflare and use their nameservers.
  • I see that the certificate is active, and there now is a “worker” entry in the DNS.

All should be well, but…

Problem:
The webpage shows a 522 error on the custom domain (but not the dev environment), so I can’t access the worker over the custom domain.

Second experiment:
I added the subdomain as a worker route. It still does not work and shows the same 522 error. I fear that the remark below is relevant.

Additional info:
I have a long history of problems with Cloudflare domains and fuzzy errors, and they seem to be originating from my account being somehow corrupted over time (I don’t know why, last time they said “it has been resolved” without explanation - but that solution took weeks and lots of begging for support). However, that makes debugging tricky as I constantly think that it may be that weird situation again - so I am kinda hoping that some of you will tell me that my current problems are resolvable.

Can support help me out?

Yes, but no. I host many web apps on CF, all the ones that predate this work fine.