WARNING: Can't verify CSRF token authenticity in case of API development

后端 未结 2 1887
时光取名叫无心
时光取名叫无心 2020-12-08 00:06

I am right now developing web APIs with Ruby on Rails. When the Rails app receives POST request without any csrf token, the following error message shall ha

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 00:46

    For rails 4 it should be

    skip_before_action :verify_authenticity_token, only: [:one_or_two_actions_here]
    

    Note that you should avoid skipping verify_authenticity_token on all actions of your controller, instead use the option only to skip only where you have to. See the docs

提交回复
热议问题