import OsfAdapter from './osf-adapter';

export default DS.JSONAPIAdapter.extend({
    host: 'http://localhost:8000',
    buildURL(modelName, id, snapshot, requestType) {
        // Fix issue where CORS request failed on 301s: Ember does not seem to append trailing
        // slash to URLs for single documents, but DRF redirects to force a trailing slash
        var url = this._super(...arguments);
        if (requestType === 'deleteRecord' || requestType === 'updateRecord' || requestType === 'findRecord') {
            if (snapshot.record.get('links.self')) {
                url = snapshot.record.get('links.self');
            }
        }
        if (url.lastIndexOf('/') !== url.length - 1) {
            url += '/';
        }
        return url;
    },
});

@@ -4,42 +4,30 @@
 ort 
-OsfAdapter from './osf-adapter
+DS from 'ember-data
 ';%0A
-%0A
 expo
@@ -745,12 +745,332 @@
 %0A    %7D,%0A
+    ajax: function(url, method, hash) %7B%0A%09%09hash.crossDomain = true;%0A%09%09hash.xhrFields = %7BwithCredentials: true%7D;%0A%09%09return this._super(url, method, hash);%0A  %09%7D,%0A  %09headers: Ember.computed(function() %7B%0A%09    return %7B%0A%09      %22X-CSRFToken%22: Ember.get(document.cookie.match(/csrftoken%5C=(%5B%5E;%5D*)/), %221%22)%0A%09    %7D;%0A  %09%7D).volatile()%0A%0A
 %7D);%0A

Switch to JSONAPIAdapter with cross domain and csrf headers