Lack of origin variable in sentry_data causing X-Sentry-Error:Missing required Origin or Referer header
I'm an intermediate programmer so I apologize if this is in error! I'm getting Missing required Origin or Referer header as part of a 400 response, even though I've set SENTRY_ALLOW_ORIGIN = "*" in my settings.py file. I think the issue is that my sentry_data query string only sends a referer variable, not an origin variable. In raven-python/raven/contrib/django/views.py, line 48, origin = request.META.get('HTTP_ORIGIN') returns nothing for me. I was looking at the source in sentry/src/sentry/web/api.py and there they put
def get_request_origin(self, request): """ Returns either the Origin or Referer value from the request headers. """ return request.META.get('HTTP_ORIGIN', request.META.get('HTTP_REFERER'))
which defaults to the referer variable if the origin variable isn't present (as in my case). Does it make sense to add that line on line 148 here? Thanks for your time, I couldn't find a way to include the HTTP_ORIGIN variable in my query string so decided to post here, sorry if this isn't a correct issue!
I would actually avoiding using the undocumented proxy views contained in raven-python.
Actually I think this ticket is invalid so I'm going to close it out.
The header/origin are HTTP variables (not the sentry headers), and these come from the JS client.
I still think this is an issue. I just spend several hours trying to figure out why 7.1.4 won't accept any requests. I then did the following:
- Started completely from scratch (removed everything related to Sentry)
- Installed 6.4.4
- Configured Raven.JS with the correct API key
- Saw it actually made an event in Sentry
- Shut down Sentry, upgrade to 7.1.4
- Made sure the config.py was setup correctly (like before the upgrade)
- Start up again, get the message "Missing required Origin or Referer header"
I didn't change the API key, but suddenly it doesn't work. I can see in the request that doesn't send the Origin header, only the Referer. But that didn't change from before the upgrade. By the way, the http status is 200, not 400 (at least in my case).
We test both Origin and Referrer. If it's sending it, then the server is declining it based on some other reason.
Do you have any suggestions on what to do from here? It works on 6.4.4, but not on 7.1.4, even though nothing changed (except Sentry, of course). There's only one place in the code where that statement can come from (web/api.py). This means that origin is None (and not is_valid_origin), even though Access-Control-Allow-Origin is set to the exact same string as Referer on the request. I would like to poke around and debug some more, but I'm really not that good with python.
Can you confirm the exact headers sent and received? Specifically Referer and X-Sentry-Error.
I'm sorry, I'm an idiot. To save time, I didn't start celery. Which probably meant that the events were queued, but never processed. When I disabled celery, it worked.
Just saw this again - my problem was actually that I upgraded my site with an SSL certificate, and therefore needed to start pulling the https version on the cdn. I.e.,
'sentry_public_dsn': get_client().get_public_dsn('https')
Hi SizeSeeker, could you please tell me where you put that line ? I am having the exact same issue