steem-js
steem-js copied to clipboard
XMLHttpRequest cannot load https://api.steemit.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource.
I made a GET request (request that doesn't modify the blockchain) and got an error.
Expected behavior
No error is returned.
Actual behavior
XMLHttpRequest cannot load https://api.steemit.com/.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access.
The response had HTTP status code 504.
How to reproduce
Execute get requests repeatedly until the error pops up. Occurs very rarely.
Environment information
Ubuntu 16.04
All API calls are POST
requests. Can you provide some sample code to reproduce this?
Well basically I'm executing the code from the console on no domain (just an open browser). The error happens rarely, it's not deterministic. It's good to know that all calls are POST.
After doing some more research, it seems that the 504 code means that the API acted as a "gateway" for the blockchain and the blockchain timed out in its response. Does that seem like a reasonable explanation?
The current solution I'm trying out is to just swallow all errors from "would-be" GET requests, as they most likely indicate a network error.
Do you think this is a reasonable to handle this problem?
Same sudden issue here. The API was just working fine till today for me.
The funny part is, that it only gave me problems once I deleted my browser cache.
Failed to load https://api.steemit.com/: Response to preflight
request doesn't pass access control check: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'https://localhost:8080'
is therefore not allowed access.
It honestly just seems like the blockchain is failing to respond. I didn't have this problem before either.
This is so annoying. I keep getting 504's sporadically for all types of requests. It'll just happen once every like 10 requests. I also tried using the dsteem library instead but it's the same issue. Almost certain that it's an issue with api.steemit.com.
The simplest solution would be to use different node, for example:
steem.api.setOptions({url: 'wss://steemd-int.steemit.com'});
Right but I haven't found a single one that works reliably. steemd-int.steemit.com is really fast and doesn't have the 504 errors but after 5-10 minutes, the connection closes and you're unable to use it anymore in your session.
Hmm... I can only suppose, but maybe you are making to many requests and to not let you overload node you'd been hold back for some time on making requests? (I don't know its only my guess)