How can I restrict protect_from_forgery with exception rails
06:40 31 Aug 2015

I have a rails application that is both a regular web page and an API. I have activated the

protect_from_forgery with: :exception

in the ApplicationController and because of that I'm getting errors when doing POST request to the API (422 responses).

So I want to restrict the

protect_from_forgery with: :exception

to the regular and put

protect_from_forgery with: :null_session 

to my API(Which is under the API/v1 namespace). How can I do that?

ruby-on-rails ruby security