Skip to content

Change react-native plugin to use HTTP POST w/ phony Origin (fixes #493) #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions plugins/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function reactNativePlugin(Raven) {
}

function xhrTransport(options) {
options.auth.sentry_data = JSON.stringify(options.data);

var request = new XMLHttpRequest();
request.onreadystatechange = function (e) {
if (request.readyState !== 4) {
Expand All @@ -46,8 +44,12 @@ function reactNativePlugin(Raven) {
}
};

request.open('GET', options.url + '?' + urlencode(options.auth));
request.send();
request.open('POST', options.url + '?' + urlencode(options.auth));
// Sentry expects an Origin header when using HTTP POST w/ public DSN.
// Just set a phony Origin value; only matters if Sentry Project is configured
// to whitelist specific origins.
request.setRequestHeader('Origin', 'react-native://');
request.send(JSON.stringify(options.data));
}

// react-native doesn't have a document, so can't use default Image
Expand Down