I'm trying to catch in JS and log to Sentry an error thrown when doing AJAX GET
request to the API where CORS
is disabled. I can't get the error message in jQuery fail()
function nor in $(document).on({ajaxError:...})
. The only content of my xhr
object is {"readyState":0,"withCredentials":true,"status":0,"statusText":"error"}
I see, however, the following messages in my console: Error
Access to XMLHttpRequest at 'https://***/' from origin 'https://***' has been blocked by CORS policy: Response to reflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
thrown by my HTML file, and a warning
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://***/ with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
thrown by raven.js
.
Is there any option to capture these messages in JS as they are seen in colsole?
I'd like to underline, that I don't want to get rid of CORS error (set *
, etc). I just want to catch it.