我有一个仅限 Rails 5 API 的应用程序,想要在 JSON 请求的响应中发送 cookie。当我使用 ActionDispatch::Cookies 在请求的响应中设置 cookie 时,它不会Set-Cookie在响应中设置标头。虽然response.set_cookie确实有效。
我还在应用程序控制器中进行了钩子测试after_action,我看到Set-Cookieheader 不存在于 response.headers 中,但存在 cookies['name_of_cookie'] 。我还想问的一个问题是这些 cookie(ActionDispatch::Cookies) 何时设置响应头?它发生在机架中吗?
withCredentialsAccess-Control-Allow-Credentials: true和Access-Control-Allow-Origin: <origin (request.headers['origin'])>存在config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, key: '_namespace_key'
Run Code Online (Sandbox Code Playgroud)
afterRails 应用程序中的任何回调挂钩中,还是发生在机架中?因为直到after_action在 applicaton_controller 中标题才不存在。domaincookie的设置有关系?我还在生产中使用 secure 和 httponly cookie,但在开发中仅使用 httponly。 …每当我这样做时:
sudo apt-get 更新
我收到以下错误:
W: GPG error: http://ppa.launchpad.net/rael-gc/rvm/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8094BB14F4E3FBBE
W: The repository 'http://ppa.launchpad.net/rael-gc/rvm/ubuntu xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/xenial/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed …Run Code Online (Sandbox Code Playgroud)