ruby on rails 关闭 csrf token 验证

作者在 2023-07-05 16:49:17 发布以下内容
在 app/controllers/application_controller.rb 加入 “skip_before_action :verify_authenticity_token”,比如:
class ApplicationController < ActionController::Base
  include ApplicationHelper

  skip_before_action :verify_authenticity_token    # 就是加这行

  before_action :check_login

  # and so on ...............
end
参考:
https://stackoverflow.com/a/5669355/873610
https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-skip_forgery_protection

Ruby | 阅读 557 次
文章评论,共0条
游客请输入验证码
浏览2872594次
文章归档
最新评论
  • 时光拾荒者:CtrlCV还是强的😝
  • 硬识岩丝:解决了,太感谢了~
  • xiwang12:路过
  • 里苦不功:不校验mysql版本是否与当前django框架是否兼容