title: Protection from json with authentication token
body: <p>I have a Rails application and I make requests through posts and I respond on json, however, because of this line</p>
  
  <pre><code>protection_from_forgery with: :exception
  </code></pre>
  
  <p>it doesn't let me proceed the request, I read somewhere that adding this line instead of the previous would help</p>
  
  <pre><code>protect_from_forgery unless: -&gt; {request.format.json?} 
  </code></pre>
  
  <p>And, in fact, it does help, but I'm not sure that it's right to remove the line in the past just to accept json, what could be the right way to do this without removing the exception in the first line? </p>