rails - “WARNING: Can't verify CSRF token authenticity” for json devise requests

前端 未结 10 2191
终归单人心
终归单人心 2020-11-27 10:11

How can I retrieve the CSRF token to pass with a JSON request?

I know that for security reasons Rails is checking the CSRF token on all the request types (including

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 10:29

    Also for development/test mode.

    protect_from_forgery with: :exception unless %w(development test).include? Rails.env
    

    This warning shows because you are using :null_session, in Rails 4.1 it works by default if no with: options specified.

    protect_from_forgery
    

提交回复
热议问题