emberjs / data

A lightweight reactive data library for web applications. Designed over composable primitives.
https://api.emberjs.com/ember-data/release
Other
3.03k stars 1.33k forks source link

JSONAPI adapter content-type is being blanked over by application/vnd.api+json on POST #6167

Closed Benjy1979 closed 5 years ago

Benjy1979 commented 5 years ago

Reproduction

Please provide one of the following:

Check POST in the model adapters of CreateRecord call.

Description

See this for description

Versions

Run the following command and paste the output below: npm ls ember-source && npm ls ember-cli && npm ls ember-data.

ember-roomviewer-bighomeshop@0.0.0 C:\inetpub\wwwroot\ember-roomviewer-bighomeshop
`-- ember-source@3.10.1

ember-roomviewer-bighomeshop@0.0.0 C:\inetpub\wwwroot\ember-roomviewer-bighomeshop
`-- ember-cli@3.10.1

ember-roomviewer-bighomeshop@0.0.0 C:\inetpub\wwwroot\ember-roomviewer-bighomeshop
`-- ember-data@3.10.0

P.S. If any of the packages show more than one installed version, that may be the root cause of the issue!


Thanks again!

The ember-data Team <3

Benjy1979 commented 5 years ago

I've put a project showing simple program to reproduce the issue: Here is a repository

The application route has CreateRecord in it. It will use the plan adapter (as proven by the alert("Called this"); appearing in the application route).

It makes this request in chrome. I can see the x-access-token there look, but the content-type is not set.

Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Origin: http://localhost:4200
Referer: http://localhost:4200/
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Mobile Safari/537.36
x-access-token: TOKENHERE
X-Requested-With: XMLHttpRequest
runspired commented 5 years ago

@Benjy1979 if you properly case to Content-Type is it set?

Benjy1979 commented 5 years ago

No it stays the same

runspired commented 5 years ago

I think this will resolve it: https://github.com/emberjs/data/pull/6169

Benjy1979 commented 5 years ago

How do I get hold of the changes, I'm not too familiar with what I can do with that link. 1 of the tests are failing.

I normally just use ember-cli-update

runspired commented 5 years ago

@snewcomer was this fixed by #6341 ?

snewcomer commented 5 years ago

Yes it was! At least for the fetch case - https://github.com/emberjs/data/pull/6341/files#diff-ad84fbc878beedc97078e5053b8e41d7R1102

For ajax, it is relying on contentType and shouldn't be blanking over it anymore!

Benjy1979 commented 4 years ago

Ah yes it is working now, my extended adapter for a particular model is reading the header callback and the request has the specified one in the request. Thrilled, and thanks very much.