Closed webqap closed 6 years ago
Not possible. No exchanges allow connections to their API via the browser or plugins due to CORS/cross origin security issues
Ah yes that is true.
Though I think you can bypass the CORS issues by creating a custom dns/hosts entry on your local machine. For example:
cors.binance.com 127.0.0.1
Then the browser wouldn't complain anymore.
Thanks for getting back!
hi, I was wondering today, how to implement the library in my browser. Since this post is 3 years, old, is this still not possible?
it can be done using electron and vue i believe, and there's a couple new executable build tools as well. haven't really stayed on top of this but I have done it.
You can also make a CORS wrapper on a webserver (or serverless) to act as a proxy since binance forbids browser requests except on binance.com. This way you can run without electron, in the native browser, and still make connections. I started on this project but only got a few functions and websocket working. I can share the source, but not my proxy. Basically just need the data from Binance without going through binance.com
for nginx there are reverse websocket proxies as well and I managed to get one working on apache
Reverse proxy example: instead of accessing wss://stream.binance.com/klines/btcusdt
I access wss://mydomain.com/stream/klines/btcusdt
for example, and I don't even have a https certificate since cloudflare handles that for me (flexible ssl)
ok, thank you! amI still trying to figure out if it's possible to create one single javascript file from the node package that I could embed in a Githubissues.
Hi. What would be the best way to use this library in the browser?