import ApplicationAdapter from 'ember-jsonapi-resources/adapters/application';
import config from '../config/environment';

export default ApplicationAdapter.extend({
  type: 'proposal',

  url: config.APP.API_HOST +  '/proposals',

  // FIXME: This is a hack to make ember-jsonapi-resources work with ember-simple-auth.
  // It overrides fetch() options to include the bearer token in the session.
  // I'll post an issue on ember-jsonapi-resources and see if there's a better way.
  fetchOptions(options) {
    let isUpdate;
    options.headers = options.headers || { 'Content-Type': 'application/vnd.api+json' };
    // const authHeader = window.localStorage.getItem('AuthorizationHeader');
    const simpleAuthSession = JSON.parse(window.localStorage.getItem('ember_simple_auth:session'));
    const accessToken       = simpleAuthSession.secure.access_token;
    const authHeader        = 'Bearer ' + accessToken;

    if (authHeader) {
      options.headers['Authorization'] = authHeader;
    }
    if (typeof options.update === 'boolean') {
      isUpdate = options.update;
      delete options.update;
    }
    return isUpdate;
  }
});

import ApplicationAdapter from 'ember-jsonapi-resources/adapters/application';

export default ApplicationAdapter.extend({
  type: 'proposal',

  url: /*config.APP.API_PATH + */ '/proposals',

  /*fetchUrl: function(url) {
    const proxy = config.APP.API_HOST_PROXY;
    const host = config.APP.API_HOST;
    if (proxy && host) {
      url = url.replace(proxy, host);
    }
    return url;
  }*/
});

--- 
+++ 
@@ -1,16 +1,29 @@
 import ApplicationAdapter from 'ember-jsonapi-resources/adapters/application';
+import config from '../config/environment';
 
 export default ApplicationAdapter.extend({
   type: 'proposal',
 
-  url: /*config.APP.API_PATH + */ '/proposals',
+  url: config.APP.API_HOST +  '/proposals',
 
-  /*fetchUrl: function(url) {
-    const proxy = config.APP.API_HOST_PROXY;
-    const host = config.APP.API_HOST;
-    if (proxy && host) {
-      url = url.replace(proxy, host);
+  // FIXME: This is a hack to make ember-jsonapi-resources work with ember-simple-auth.
+  // It overrides fetch() options to include the bearer token in the session.
+  // I'll post an issue on ember-jsonapi-resources and see if there's a better way.
+  fetchOptions(options) {
+    let isUpdate;
+    options.headers = options.headers || { 'Content-Type': 'application/vnd.api+json' };
+    // const authHeader = window.localStorage.getItem('AuthorizationHeader');
+    const simpleAuthSession = JSON.parse(window.localStorage.getItem('ember_simple_auth:session'));
+    const accessToken       = simpleAuthSession.secure.access_token;
+    const authHeader        = 'Bearer ' + accessToken;
+
+    if (authHeader) {
+      options.headers['Authorization'] = authHeader;
     }
-    return url;
-  }*/
+    if (typeof options.update === 'boolean') {
+      isUpdate = options.update;
+      delete options.update;
+    }
+    return isUpdate;
+  }
 });
Make ember-jsonapi-resources work with ember-simple-auth, by overriding fetch() options to include the bearer token in the session.
