In my rails app I'm getting "WARNING: Can't verify CSRF token authenticity" on an ajax post to an api.
app/views/layouts/application.html.haml :
!!!
%html
%head
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
= yield
ajax post :
$.ajax({ url: '#{card_credits_path}',
type: 'POST',
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', '#{form_authenticity_token}')},
dataType: "json",
data: { credit_uri: response.data.uri,
email: $('#email:hidden').val(),
name: $('.name').val()
},
success: function(randomobject) {
window.location = '/';
},
error: function(){
console.log("Card information is wrong!");
}
});
form_authenticity_token
? What are the contents? – zeantsoi