ChristofferJoergensen ChristofferJoergensen - 9 months ago 40
Ajax Question

POST request done with Authenticity Token, but exception still rased

My controller is responding to a js GET request, and in my

file I am reporting back with the
generated browser data of the users browser. This is done with a POST request, because of the large data string, so I have inserted a
method that adds the Authenticity Token.

However, this is rejected with
ActionController::InvalidAuthenticityToken - ActionController::InvalidAuthenticityToken
. When I check, the header looks like it does in the GET requests that succeed:


The js code looks like this:

(new Fingerprint2).get(function(fingerprint, components) {
return $.ajax({
url: "/user_browser",
type: "post",
beforeSend: function(xhr) {
data: {
some_id: '123',
components: JSON.stringify(components),
fingerprint: fingerprint
dataType: "json"
}).success(function(data) {});


I found the root of the problem. Some days ago I changed my config/session_store.rb from:

MyApp::Application.config.session_store :cookie_store, key: '_my-app_session'


MyApp::Application.config.session_store :disabled

When I changed this back the problem disappeared.