Getting 502 Bad Gateway When Accessing an External API

Hi
I’m trying to access HuggingFace’s Inference API. It works great when the Worker is run on local environment but as soon as I publish it production, the API response returns 502 Bad Gateway with exactly the same code base and API token.
Kindly help