Fileupload to remote server

I just created a new project on other machine and tested the file upload with ember. It is working and files are being stored. So on my Mac, I have started a new ember app and slowly started to add each addon and started to configure. Checking file upload on each step.

Finally drilled down to my custom authorizer which I have used for simple auth, which is

import Ember from 'ember';
import Base from 'simple-auth/authorizers/base';

export default Base.extend({
  authorize: function(jqXHR, requestOptions) {
   // requestOptions.contentType = 'application/json;charset=utf-8';   <--- this line is creating the issue 
    requestOptions.crossDomain = true;
    requestOptions.xhrFields = {
      withCredentials: true
    };

    var token = this.get('session.token');
    if (this.get('session.isAuthenticated') && !Ember.isEmpty(token)) {
      jqXHR.setRequestHeader('X-CSRF-Token', token);
    }
  }
});

Any suggestions on improving this code? I had got it from Ember-simple-auth with REST API and session cookie - #5 by haggis

If I comment the line then I can not login to simple auth.

  1. Comment the line
  2. Login unsuccessful
  3. Uncomment the line so authorizer can work,
  4. Login, successful
  5. go to upload page
  6. Try to upload file didnt got uploaded
  7. commented the line in authorizer and tried again. File is uploaded to server

Here is my finding. When I have commented the line, the login page send data as Content-Type:application/x-www-form-urlencoded; charset=UTF-8 and I am not logged in on the server. I get 401. But if I am logged in all the other communication to the server is still made via Content-Type:application/json; charset=utf-8 and the file upload page use Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryyFVyavl08YPMzfmb and file is received on the server.

So simple-auth’s custom authentorizer is overriding the file upload multipart/form-data as json and which is the problem