Hi all, I am using ember 3.28.
Any request from rest adaptor does not send cookie which has session id, here is my adaptor
import RESTAdapter from '@ember-data/adapter/rest';
export default class StudentAdapter extends RESTAdapter {
host = 'http://localhost:8082/Backend';
namespace = 'api';
}
Can anyone provide suggestions to how to send cookie with rest adaptor request
Hi @santhoshit8, welcome!
I would highly recommend looking at ember-simple-auth if you haven’t already. It’s so popular it may as well be a core addon and it helps you set up an application for exactly this sort of thing.
Basically you would set it up with a cookie store, then in your adapter use a snippet like the example in the docs to provide your authentication data from the injected session service.
1 Like
Hello @dknutsen . Thanks for quick reply.
I would try to implement ember simple auth.
I have seen following in stackoverflow
import Ember from 'ember';
$.ajaxSetup({
xhrFields: {
withCredentials: true
}
});
export default DS.RESTAdapter.extend({
ajax(url, method, hash) {
hash = hash || {};
hash.crossDomain = true;
hash.xhrFields = {
withCredentials: true
};
return this._super(url, method, hash);
}
})
can we have any option like these in ember 3.28.
I have tried something but could not able to get work done.
Ember no longer uses jQuery under the hood (by default at least) so that method won’t cut it anymore. I’d highly recommend using the setup outlined in the ember-simple-auth guides (setting the headers via a computed getter in your application adapter).