我有一个Rails应用程序,在这个应用程序中,我在前端的某些部分使用Vue (通过webpacker)。
在Vue中,我调用了我的服务器,它需要访问current_user (Devise),但是,我得到的无法验证CSRF令牌的真实性。错误和当前用户不被返回。
为了避免这种情况,我跳过了这样的before_action:
skip_before_action :verify_authenticity_token, only: :stripe_vue
def stripe_vue
...
end然而,我仍然得到了完全相同的问题。
这有点奇怪,因为我正在做的与另一个控制器中的完全相同,它的工作原理就像魅力一样。
发布于 2017-10-30 08:16:15
评论这一行
protect_from_forgery with: :exception最后的代码应该如下所示
skip_before_action :verify_authenticity_token
#protect_from_forgery with: :exceptionhttps://stackoverflow.com/questions/47009966
复制相似问题