How to turn off rails protect_from_forgery filter only for json

后端 未结 3 639
一向
一向 2021-01-17 22:35

I have web site built with Rails3 and now I want to implement json API for mobile client access. However, sending json post request from the client because of the protect_fr

3条回答
  •  渐次进展
    2021-01-17 23:29

    Add the code below to your ./app/controllers/application_controller.rb:

    protect_from_forgery unless: -> { request.format.json? }
    

提交回复
热议问题