In my Rails application, I have implemented a feature that allows users to post answers to questions via ajax. Everything was working fine until I decided to incorporate the aws-js-sdk
script in order to enable image uploads within the answer input field. The images are uploaded to S3 and the URL of the uploaded image is returned in a callback function, after which I save the answer.
The library was added to the application using the following code snippet:
<%= javascript_include_tag "//sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js" %>
Expected behavior: When submitting an answer with an image, the request header should contain HTTP_X_CSRF_TOKEN
to validate that the form submission originated from within the website.
Issue: However, the request header does not include HTTP_X_CSRF_TOKEN
, resulting in the error message
ActionController::InvalidAuthenticityToken
.