Sentry: Cannot report error with JavaScript client : CORS Error

Created on 7 Feb 2019  路  2Comments  路  Source: getsentry/sentry

Important Details

How are you running Sentry?

  • [x] On-Premise Manual Installation v9.0
  • [ ] Saas (sentry.io)
  • [ ] Other [briefly describe your environment]

I'm on a clean 9.0 install, using the version 3.26.2 of the Raven Client.
I also use Nginx as a proxy between my client and Sentry.

Description

Reporting an error from Raven JavaScript client throws a CORS exception :

Stack Trace :

raven.min.js:2 POST http://sentry.[domain].com//api/3/store/?sentry_version=7&sentry_client=raven-js%2F3.26.2&sentry_key=[key] 403 (OK)
(anonymous) @ raven.min.js:2
_makeRequest @ raven.min.js:2
qa @ raven.min.js:2
Y @ raven.min.js:2
fa @ raven.min.js:2
V @ raven.min.js:2
captureException @ raven.min.js:2
d @ raven.min.js:2

JavaScript error in the console :

(index):1 Access to fetch at 'http://sentry.[domain].com//api/3/store/?sentry_version=7&sentry_client=raven-js%2F3.26.2&sentry_key=[key]' from origin 'http://127.0.0.1:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Sentry also output some logs when the error happens :

12:06:08 [WARNING] django.request: Forbidden (CSRF cookie not set.): /api/3/store/ (status_code=403 request=<WSGIRequest: POST u'/api/3/store/?sentry_version=7&sentry_client=raven-js%2F3.26.2&sentry_key=[key]'>)
127.0.0.1 - - [07/Feb/2019:12:06:08 +0000] "POST //api/3/store/?sentry_version=7&sentry_client=raven-js%2F3.26.2&sentry_key=[key] HTTP/1.0" 403 5949 "http://127.0.0.1:8000/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36"

Reporting errors from Raven Python client works well.

Thank you for your help.

Most helpful comment

I also encountered the same problem, but I don't know how to solve it
image

All 2 comments

Using Sentry SDK fixed the issue.

I also encountered the same problem, but I don't know how to solve it
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bruno-garcia picture bruno-garcia  路  3Comments

sul4bh picture sul4bh  路  3Comments

gocarlos picture gocarlos  路  3Comments

nickolaskraus-wf picture nickolaskraus-wf  路  3Comments

dcramer picture dcramer  路  4Comments