Instead of just filling out the form in HTML it should also be possible to just send a post request containing the params.. Is it possible to turn off the authenticity token if, for example, the Accept flag is set to ‘application/JSON’ in the HTTP header?
Share
The request forgery protection works on the basis of checking the content-type of requests and it only checks the requests that can be made by a browser. No browser is able to generate a request with the content-type set to ‘application/json’ for example. That’s why the rails forgery protection routine won’t check it. So, if you want to make a json request to your application, set the content-type header to ‘application/json’ and it should work.