Axios: Cookie 不会随发布请求自动发送!

创建于 2017-09-07  ·  3评论  ·  资料来源: axios/axios

概括:
在之前的 _get_ 调用中收到的 Cookie 不会使用以下 _post_ 命令发送。

细节:
我正在使用以下调用序列登录后端。

axios.get(Url.csrfToken(), { withCredentials: true })
            .then(response => response.data)
            .then(token => axios.post(Url.authenticate(), { username, password }, {
                    headers: {
                        'content-type' : 'application/x-www-form-urlencoded',
                        'crsf-token' : `${token.csrfToken}`
                    },
                    withCredentials: true
                })
            )
            .then(response => console.log('completed'))
            .catch(error => console.log(error))

_post()_ 需要在 _get()_ 的响应标头中以set-cookie返回的 Cookie。

但是 post() 在其 header 中没有任何 cookie ,导致失败。

我该如何解决它,请帮忙?

环境

  • 反应:16.0.0-alpha.12
  • 反应原生:0.47.2
  • iOS 模拟器 - 10.0 版

最有用的评论

这有帮助吗?

https://stackoverflow.com/questions/46288437/set-cookie-header-has-no-effect

2017 年 9 月 25 日星期一 22:28,Chris Gillis [email protected]写道:

也很好奇


您收到此消息是因为您订阅了此线程。
直接回复此邮件,在 GitHub 上查看
https://github.com/mzabriskie/axios/issues/1076#issuecomment-332002134
或使线程静音
https://github.com/notifications/unsubscribe-auth/AVepSmu6HPCE7R-bdBHXU4wa12co56ekks5smAzWgaJpZM4PPYy9
.

所有3条评论

@varmeh你是怎么解决这个问题的?

也很好奇

这有帮助吗?

https://stackoverflow.com/questions/46288437/set-cookie-header-has-no-effect

2017 年 9 月 25 日星期一 22:28,Chris Gillis [email protected]写道:

也很好奇


您收到此消息是因为您订阅了此线程。
直接回复此邮件,在 GitHub 上查看
https://github.com/mzabriskie/axios/issues/1076#issuecomment-332002134
或使线程静音
https://github.com/notifications/unsubscribe-auth/AVepSmu6HPCE7R-bdBHXU4wa12co56ekks5smAzWgaJpZM4PPYy9
.

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

zackseuberling picture zackseuberling  ·  83评论

cruelbob picture cruelbob  ·  37评论

huy-lv picture huy-lv  ·  43评论

jonathan-stone picture jonathan-stone  ·  69评论

Donovantxy picture Donovantxy  ·  58评论