I want to build a rails app with two different protect_from_forgery strategies: one for the web application, and one for the API.
In my application controller I have thi
I am running an application with a similar structure - Web App + API. I solved the CSRF problem like this:
Code:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, if: :isWebRequest?
def isWebRequest?
request.subdomains[-1] != 'api'
end
end