return 522 using fetch in a worker to request api of another worker
When a worker requests the api under the domain name bound by another worker, 522 is returned. "The initial connection between Cloudflare's network and the origin web server timed out". But at the same time, the api of the worker accessed can be accessed normally on the public network. . the error page shows i can find more info here but results of
2 Replies
solved by using service binding
Nice, Service bindings are indeed the correct way to solve this.
The underlying reason is Same zone (domain) Worker Requests will bypass the other worker and try to use the non-existent origin behind the worker. If they are on a different zone, the worker request will invoke the other worker properly.
more full explanation & reasoning: https://community.cloudflare.com/t/issue-with-worker-to-worker-https-request/94472/8?u=chaika