Wednesday, September 14, 2016

Request header does not include HTTP_X_CSRF_TOKEN when using AWS JS SDK

Leave a Comment

I have a Rails application where I can post answers to questions via ajax, it works fine, however, I have added the aws-js-sdk script to be able to upload images in my answer from the browser, the image will be uploaded to s3 which sends back the url of the newly uploaded image in a callback, then I save the answer.

I included the library like this :

 <%= javascript_include_tag "//sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js" %> 

Expected behaviour : when I submit an answer with an image, the request header should include HTTP_X_CSRF_TOKEN to verify the form is submitted from within my website.

Problem : request header does not include HTTP_X_CSRF_TOKEN, which is leading to the error ActionController::InvalidAuthenticityToken

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment