-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[BUGFIX]: set Content-Type for non GET requests only #6341
[BUGFIX]: set Content-Type for non GET requests only #6341
Conversation
packages/adapter/addon/json-api.js
Outdated
@@ -143,6 +143,8 @@ import { pluralize } from 'ember-inflector'; | |||
const JSONAPIAdapter = RESTAdapter.extend({ | |||
defaultSerializer: '-json-api', | |||
|
|||
defaultContentType: 'application/vnd.api+json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps privatize with _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please
options = fetchOptions(options, this); | ||
} else { | ||
if (options.data && options.type !== 'GET') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A GET request with a non-simple content-type will result in a preflight request. One consequence of adding the Content-Type
header on GET (where we used to not) is the backend server perhaps doesn't expect this and won't return the right a-c-a-o header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave this explanation of this conditional as a comment in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall is good but needs a tiny bit of cleanup prior to merge
4fc3201
to
f336432
Compare
@snewcomer Is this fix part of any release? |
@brandynbennett it is in beta |
Awesome thanks!
… On Oct 8, 2019, at 7:40 PM, Chris Thoburn ***@***.***> wrote:
@brandynbennett it is in beta
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Piggybacked off of #6169 with some tests and default content type header
close #6341 #6167 #6324