tiagosiebler / bybit-api

Node.js SDK for the Bybit APIs and WebSockets, with TypeScript & browser support.
https://www.npmjs.com/package/bybit-api
MIT License
244 stars 80 forks source link

Bybit API & CORS #79

Closed blake41 closed 2 years ago

blake41 commented 3 years ago

Apologies if this is a stupid question. I'm trying to run the bybit-api module in my browser. I'm using a CORS extension in chrome to allow CORS request from any origin but keep getting a CORS issue when I try and use the bybit-api library. I can make requests directly myself when I hit the actual bybit api manually with an axios get request in a JS script so I'm not sure why axios in bybit-api is not being allowed to make CORS requests

tiagosiebler commented 3 years ago

Would love to gather some of the options in one place. Primarily this comes down to how bybit's APIs are configured, as they need to include a few headers in their responses for browsers to happily make requests.

These are the possible solutions that come to mind from my side:

Would be curious if for development any browser extensions can help here but I haven't tried that personally...

blake41 commented 3 years ago

Thanks! Going with the second option. Was trying to avoid setting up a server and just do some simple dev in browser but CORS is such a pain. I've gotten away with it in the past using browser extension that allow CORS but ran into some issues

pixtron commented 3 years ago

There is still an open issue regarding CORS on bybit's side: bybit-exchange/bybit-official-api-docs/issues/29.

tiagosiebler commented 3 years ago

There is still an open issue regarding CORS on bybit's side: bybit-exchange/bybit-official-api-docs/issues/29.

Yes unfortunately. Spoke to them a few times about it. Last time (few months ago) they stated they still had no plans on changing this on their side yet. Best recommendation is to keep asking them about it so they're aware of demand, while using one of the above suggestions in the meantime (unless other ideas come to mind ofc).

tiagosiebler commented 2 years ago

Closing this but leaving it pinned for visibility.

tiagosiebler commented 2 years ago

Announced today:

CORS support has been added to the Futures API. This means that frontend JavaScript code can directly call the Futures API due to the presence of the response header

Access-Control-Allow-Origin: *

A huge thank you to the many users who requested this change. You feedback improves the Bybit API!