mercredi 30 septembre 2015

Rails + Emberjs: Can't verify CSRF token authenticity

I'm new to using rails as an api with an Emberjs front-end. I'm getting a 'Completed 422 Unprocessable Entity' and Can't verify CSRF token authenticity whenever I try to do a POST request

I've seen a couple of posts and solutions saying to insert this function

$(function() {
    var token = $('meta[name="csrf-token"]').attr('content');
    return $.ajaxPrefilter(function(options, originalOptions, xhr) {
        return xhr.setRequestHeader('X-CSRF-Token', token);
    });
});

Where is the appropriate place to implement CSRF in an ember-cli project?




Aucun commentaire:

Enregistrer un commentaire