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 | 阅读 451 次
文章评论,共0条
游客请输入验证码
浏览2802879次
文章归档