0

设置 devise_token_auth。

继续解决源代码中的问题。

前任:

def token_validation_response
  as_json(except: %i[tokens created_at updated_at])
end

它将从以下位置调用:

SessionsController::create> render_create_success>token_validation_response

据我了解,您需要将令牌发送给客户端并将其存储在客户端并随每个请求一起发送。如果我们不将令牌提供给客户端和它,我不确定这应该如何工作except

except: %i[tokens created_at updated_at]

源链接: https ://github.com/lynndylanhurley/devise_token_auth/blob/c92258038c05fcc8f6a0374ccce2e63b9f8d5312/app/controllers/devise_token_auth/sessions_controller.rb#L36

https://github.com/lynndylanhurley/devise_token_auth/blob/c92258038c05fcc8f6a0374ccce2e63b9f8d5312/app/models/devise_token_auth/concerns/user.rb#L205

4

1 回答 1

0

也许这可能对某人有用。令牌出现在标题而不是正文中。

更新:

我还需要解决客户端 cors 问题。

一些有帮助的选项:

Vue Axios CORS 政策:没有“访问控制允许来源”

https://blog.bitsrc.io/how-and-why-you-should-avoid-cors-in-single-page-apps-db25452ad2f8

最简单的解决方案是在命令行中执行 chrome:

open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security

来源:https ://alfilatov.com/posts/run-chrome-without-cors/

于 2021-02-16T05:19:07.813 回答