diff --git a/app/initializers/ember-cli-rails-addon-csrf.js b/app/initializers/ember-cli-rails-addon-csrf.js index 1d8dcd4..1ef5d78 100644 --- a/app/initializers/ember-cli-rails-addon-csrf.js +++ b/app/initializers/ember-cli-rails-addon-csrf.js @@ -1,11 +1,13 @@ import Ember from 'ember'; -const { $ } = Ember; - export default { name: 'ember-cli-rails-addon-csrf', initialize() { + if (typeof $ == undefined) { + const { $ } = Ember; + } + $.ajaxPrefilter((options, originalOptions, xhr) => { const token = $('meta[name="csrf-token"]').attr('content'); xhr.setRequestHeader('X-CSRF-Token', token);