Commit a0164c26 authored by Romain Casati's avatar Romain Casati

Requests: fix + better message for CORS issue.

parent 9f5e5a78
......@@ -81,7 +81,12 @@ def request(method, url, **kwargs):
req.send(kwargs.get('data'))
def onerror(error):
raise ConnectionError(error.message)
cors_message = ""
url_origin = js.URL.new(url).origin
origin = js.window.location.origin
if url_origin != origin:
cors_message = " Requested URL is not on this domain. You may have CORS issue."
raise ConnectionError(f"{error.js_error.toString()}{cors_message} Please check error message in browser console.")
req._hacked_send = send
req._hacked_onerror = onerror
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment