-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Content-Type application/json for XHR #432
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
Add Content-Type application/json for XHR #432
Conversation
Refactor raven-js to use CommonJS modules, class instances (2.x)
Looks like you accidentally targeted master in GitHub. Unfortunately GitHub doesn't let you change the target branch, so you'll have to re-open this as a new PR against 2.x. |
Oh, and @mattrobenolt reminds me – we can't accept this patch. If we specify this Content-type header value, browsers will trigger an OPTIONS preflight request as part of CORS. It also means this request will not work at all in IE8 and IE9, since they have more limited CORS implementations. more here: http://stackoverflow.com/a/12320736 |
That however breaks on latest React / Android - adding console.log in react-native plugin gives me status: '0', message: 'Payload is set but no content-type header specified' which is coming from native java module. |
I assume we could do this for React Native without triggering the OPTIONS preflight request? |
I've decided to open an issue regardless, haven't expected such quick answer! ( #526 ) I am not sure if the above concerns also apply to React Native since native code is involved on both platforms (e.g. okhttp on android) |
Totally. My hunch is its ok for us to do it for React Native, but @benvinegar will need to confirm. Thanks for letting us know. :) |
Yeah React Native basically ignores cross-origin rules. We can implement this in the React Native transport. |
The content type should be set to JSON since it's a JSON payload.
Some servers will not interpret it as JSON otherwise. For example, node's express server middleware will not parse the body and convert it to an object.
This is against branch 2.x since master does not have the XHR feature yet. Let me know if I should resubmit against a different branch.
Thanks!