No 'Access-Control-Allow-Origin' header is present on the requested resource

2,264 views
Skip to first unread message

Giorgi Kikolashvili

unread,
Jan 18, 2016, 5:07:10 AM1/18/16
to sentry
I've set up sentry 8.0.1 with this Docker tutorial. sentry image uses port mapping 
0.0.0.0:8081->9000/tcp

webapp reports errors with this js config

<script src="https://cdn.ravenjs.com/2.0.5/raven.min.js"></script>

<script type="text/javascript">
 
Raven.config('http://22302386076d4d53...@10.11.11.144:8081/2').install();</script>
</script>

10.11.11.144 is my machines address. Both docker with sentry and webapp run on my local machine.

Chrome console shows this error when exception is thrown on webapp

XMLHttpRequest cannot load http://10.11.11.144:8081/api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.0.5&sentry_key=22302386076d4d539f4094e178fe3628. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.11.11.144:8080' is therefore not allowed access. The response had HTTP status code 400.

If I follow Sentry settings and replace 10.11.11.144 with localhost in Raven config everything works fine. I don't think this configuration will work if Sentry and webapp are deployed on different servers.


Allowed Domains and Blacklisted IP Addresses fields in Sentry configuraiton are both empty.
Am I missing something? How can I fix this CORS problem?

Request:

  1. POST /api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.0.5&sentry_key=22302386076d4d539f4094e178fe3628 HTTP/1.1 Host: 10.11.11.144:8081 Connection: keep-alive Content-Length: 611 Pragma: no-cache Cache-Control: no-cache Origin: http://10.11.11.144:8080 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 Content-Type: text/plain;charset=UTF-8 Accept: */* Referer: http://10.11.11.144:8080/myapp/Welcome.do Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,ka;q=0.6,ru;q=0.4
Response

  1. HTTP/1.1 400 BAD REQUEST Server: gunicorn/19.4.5 Date: Mon, 18 Jan 2016 08:51:03 GMT Connection: close Transfer-Encoding: chunked Vary: Accept-Language Content-Type: text/html Content-Language: en-us

David Cramer

unread,
Jan 18, 2016, 2:04:54 PM1/18/16
to gets...@googlegroups.com, Giorgi Kikolashvili
If you receive a non-200 status code from the server you should look at the ‘X-Sentry-Error’ header. It’s possible something else was misconfigured here.
--
You received this message because you are subscribed to the Google Groups "sentry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to getsentry+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Giorgi Kikolashvili

unread,
Jan 21, 2016, 6:52:38 AM1/21/16
to sentry

Sentry logs after request is made
[2016-01-21 11:30:02 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:11)
[2016-01-21 11:30:02 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:12)
[2016-01-21 11:30:02 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:13)
[2016-01-21 11:30:02 +0000] [12] [INFO] Worker exiting (pid: 12)
[2016-01-21 11:30:02 +0000] [11] [INFO] Worker exiting (pid: 11)
[2016-01-21 11:30:02 +0000] [13] [INFO] Worker exiting (pid: 13)
[2016-01-21 11:30:03 +0000] [14] [INFO] Booting worker with pid: 14
[2016-01-21 11:30:03 +0000] [15] [INFO] Booting worker with pid: 15
[2016-01-21 11:30:03 +0000] [16] [INFO] Booting worker with pid: 16
172.17.0.1 - - [21/Jan/2016:11:30:15 +0000] "GET /api/0/broadcasts/ HTTP/1.1" 200 2 "http://localhost:8082/sentry/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36"
10.11.11.144 - - [21/Jan/2016:11:30:15 +0000] "POST /api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.1.0&sentry_key=b1761c4510344da39f7de8ddad00a873 HTTP/1.1" 400 26 "http://localhost:8080/notary/Welcome.do" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36"

wireshark
POST /api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.1.0&sentry_key=b1761c4510344da39f7de8ddad00a873 HTTP/1.1
Host: 10.11.11.144:8082
Connection: keep-alive
Content-Length: 654
Cache-Control: max-age=0
Origin: http://localhost:8080

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: *

Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,ka;q=0.6,ru;q=0.4


{"project":"2","logger":"javascript","platform":"javascript","request":{"headers":{"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36","Referer":"http://localhost:8080/notary/Welcome.do"},"url":"http://localhost:8080/notary/Welcome.do"},"exception":{"values":[{"type":"Error","value":"sample","stacktrace":{"frames":[{"filename":"http://localhost:8080/notary/Welcome.do","lineno":310,"colno":19,"function":"?","in_app":true}]}}]},"culprit":"http://localhost:8080/notary/Welcome.do","message":"Error: sample","extra":{"session:duration":6},"event_id":"98ad07d24f854854bb3515905ed0c705"}HTTP/1.1 400 BAD REQUEST
Server: gunicorn/19.4.5
Date: Thu, 21 Jan 2016 11:27:16 GMT

Connection: close
Transfer-Encoding: chunked
Vary: Accept-Language
Content-Type: text/html
Content-Language: en


1A
<h1>Bad Request (400)</h1>
0


docker ps output
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
3b0b3917ba0d        sentry              "/docker-entrypoint.s"   45 minutes ago      Up 45 minutes       9000/tcp                 sentry-celery1
158321d3d81b        sentry              "/docker-entrypoint.s"   45 minutes ago      Up 45 minutes       9000/tcp                 sentry-celery-beat
4a570a7dc8f3        sentry              "/docker-entrypoint.s"   45 minutes ago      Up 45 minutes       0.0.0.0:8082->9000/tcp   my-sentry
0f5bdb43296a        postgres            "/docker-entrypoint.s"   48 minutes ago      Up 48 minutes       5432/tcp                 sentry-postgres
eba2f920d51c        redis              
"/entrypoint.sh redis"   49 minutes ago      Up 49 minutes       6379/tcp                 sentry-redis

I sent private reply by mistake :/

On Monday, January 18, 2016 at 11:04:54 PM UTC+4, David Cramer wrote:
If you receive a non-200 status code from the server you should look at the ‘X-Sentry-Error’ header. It’s possible something else was misconfigured here.


On January 18, 2016 at 2:07:12 AM, Giorgi Kikolashvili (kikola...@gmail.com) wrote:

I've set up sentry 8.0.1 with this Docker tutorial. sentry image uses port mapping 
0.0.0.0:8081->9000/tcp

webapp reports errors with this js config

<script src="https://cdn.ravenjs.com/2.0.5/raven.min.js"></script>

<script type="text/javascript">

 
Raven.config('http://22302386076d4d539f4094e178fe362...@10.11.11.144:8081/2').install();</script>
</script>

10.11.11.144 is my machines address. Both docker with sentry and webapp run on my local machine.

Chrome console shows this error when exception is thrown on webapp

XMLHttpRequest cannot load http://10.11.11.144:8081/api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.0.5&sentry_key=22302386076d4d539f4094e178fe3628. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.11.11.144:8080' is therefore not allowed access. The response had HTTP status code 400.

If I follow Sentry settings and replace 10.11.11.144 with localhost in Raven config everything works fine. I don't think this configuration will work if Sentry and webapp are deployed on different servers.


Allowed Domains and Blacklisted IP Addresses fields in Sentry configuraiton are both empty.
Am I missing something? How can I fix this CORS problem?

Request:

  1. POST /api/2/store/?sentry_version=7&sentry_client=raven-js%2F2.0.5&sentry_key=22302386076d4d539f4094e178fe3628 HTTP/1.1 Host: 10.11.11.144:8081 Connection: keep-alive Content-Length: 611 Pragma: no-cache Cache-Control: no-cache Origin: http://10.11.11.144:8080 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 Content-Type: text/plain;charset=UTF-8 Accept: */* Referer: http://10.11.11.144:8080/myapp/Welcome.do Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,ka;q=0.6,ru;q=0.4
Response

  1. HTTP/1.1 400 BAD REQUEST Server: gunicorn/19.4.5 Date: Mon, 18 Jan 2016 08:51:03 GMT Connection: close Transfer-Encoding: chunked Vary: Accept-Language Content-Type: text/html Content-Language: en-us

David Cramer

unread,
Jan 21, 2016, 12:09:15 PM1/21/16
to gets...@googlegroups.com, Giorgi Kikolashvili
Because there is no X-Sentry-Error here, it would indicate to me that the server is not appropriately receiving the request and/or headers. In every case we should be returning this header, and as it’s not, this is likely happening before it even gets to the store endpoint. 

I see in the first request that its suggested sentry is hosted at /sentry/, assuming this is true, this is not supported. You must use a subdomain for Sentry, otherwise you’re left to your own vices figuring out how to make things work.

Giorgi Kikolashvili

unread,
Jan 22, 2016, 6:50:26 AM1/22/16
to sentry
So I think I tracked down the error.
I deleted all previous docker containers and started from scratch. When I first log into sentry webapp I'm asked to provide admin mail and Root URL.
  • If Root URL is localhost external requests are not served. Even requests from same machine give error 400. Described above.
  • If Root URL is localhost and I change it to my machine ip address server responds with error 400(white screen with error code for every url path)
  • I accessed server config from my machine ip(typed 10.11.11.144 instead of localhost in browser) and saved Root URL as it was e.g. 10.11.11.144
The problem seems to be fixed now. I should read config description more carefully next time.
...
Reply all
Reply to author
Forward
0 new messages