Calling Third Party API from CloudFlare Worker
Hi Devs. I need some help. I’m trying to call a third api that is using a non-standard port (8388). I understand that CloudFlare doesn’t allow this but I’ve been told that there is a work around using CNAME in DNS settings. Does anyone know how to set this up exactly? Or another work around?
3 Replies
Hey 👋
understand that CloudFlare doesn’t allow this but I’ve been told that there is a work around using CNAME in DNS settings.Kind of, refer to this flowchart made by a community mvp:
(Zones are "Websites" in Cloudflare, anything under the websites tab)
If that third party api allowed you to custom domain to it (or otherwise does not enforce specific hostnames, which is unlikely), you could create a CNAME to it on your domain/zone, the same one the worker is bound to/executed via
The other workaround would be making your own "Proxy" API on your own infrastructure, that then proxies requests to the non-standard port
Worker -> fetch (internal-secret-proxy.mydomain.com:443 or even 8388, as long as it was same zone as worker) -> fetch (realapi.thirdpartyapi.com:8388)
Thanks for the quick response! I will try this. I really appreciate it!