-
-
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
Credentials are always set as 'same-origin' #6413
Comments
I've also had to copy-paste the following functions from ED source in order to over-write ajaxOptions properly. isPlainObject, add, serializeQueryParams and fetchOptions |
I confirm. Just noticed this issue. But from what I debugged the issue is not with config but with fetch polyfill. if you override _fetchRequest to 👍
it works :) |
Is overriding ajaxOptions(url, method, options) {
const options = this._super(...arguments);
options.credentials = 'include';
} |
This doesn't work as well. The issue is in ember-fetch polyfill |
@Exelord 👍 I'm assuming for the original For clarity, do you have |
Oh sorry, I didn't explain it well. I have custom options
and fetch override
without the override, ember-fetch is called and it looks like it does not respect this config option. No, I dont have |
Oh good! If Another note - fetch request headers are read only after they are set. Probably doesn't matter here though. |
Couple things. This does work well for my case. ajaxOptions() {
return {
...this._super(...arguments),
credentials: 'include'
};
}, Without the modifying However, in making this switch away from jQuery and ember-ajax over to fetch. The So in addition to over-ridding ajaxOptions to send credentials. I had to to override the header for content-type to be application/json. It seems ember-fetch or somewhere in there is overriding the content-type header, and doing so in a case sensitive way. If you have the header |
@optikalefx That is great to hear! Also note I merged a fix to |
With native fetch it works all fine. Its definietly polyfill issue. I also noticed that with a polyfill, received cookies are not "set" but they are sent with the request. They are like "invisible". So weird! With native fetch all works fine. |
This commit forces fetch to include credentials. There is an issue with allowing credentials with new version of Ember Data. See: See emberjs/data#6413
these sorts of issues are always difficult work arounds in adapters today. The new RequestManager streamlines this and gives full access to the request and response: emberjs/rfcs#860 |
Reproduction
https://github.com/emberjs/data/blob/master/packages/adapter/addon/rest.js#L1356
Description
Our authentication requires the use of
credentials: 'include'
. Which works fine with fetch normally. However using Ember Data it is setting credentials to same-origin no matter what you pass it. It's not possible to override just this setting.The only option we have is to overwrite the entire ajaxOptions function. Which I've done, and it works, but it's scary since ajaxOptions does so much. It would be much safer to be able to pass this option in, and ED optionally use it.
Versions
The text was updated successfully, but these errors were encountered: