Can't fetch Binance api

This code

addEventListener('fetch', (event) => {
  event.respondWith(handleRequest())
})

const handleRequest = async () => {
  const res = await fetch("https://api1.binance.com/api/v3/ticker/bookTicker?symbol=BNBBUSD")
  const json = await res.json()

  return new Response(JSON.stringify(json))
}

It’s working in preview

{"symbol":"BNBBUSD","bidPrice":"586.21000000","bidQty":"0.22590000","askPrice":"586.35000000","askQty":"2.80000000"}

But not on released version (real URL)

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>403 ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size=\"1px\">\nRequest blocked.\nWe can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.\n<BR clear=\"all\">\nIf you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.\n<BR clear=\"all\">\n<HR noshade size=\"1px\">\n<PRE>Generated by cloudfront (CloudFront)\nRequest ID: BG_FeQIL2OaqSnnj0QVGBLpEBX3BuMFZoA9h0vSgRBSlPbmnnMBv8Q==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>

And yes it’s working if I fetch somewhere else, This is mean CloudFront block Cloudflare worker fetch?
But why it’s working fine when preview?

Any workaround for this?

Thanks.

Pretty much it.

Because the test environment is located on a completely different network.

You best contact them and clarify whether they can unblock Cloudflare’s addresses.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.