
我能够在响应头中看到“Set-cookie”,但没有设置cookie.是否可以通过Axios http调用设置cookie?
Access-Control-Allow-Origin: *Connection: keep-aliveContent-Length: 355Content-Type: application/Json; charset=utf-8Date: Fri,28 Sep 2018 05:59:01 GMTETag: W/"163-PAMc87SVHWkdimTJca7oRw"Set-cookie: token=eyJhbGciOiJIUzI1NIISInR5cCI6IkpXVCJ9...; Max-Age=3.6; Path=/; Expires=Fri,28 Sep 2018 05:59:04 GMT; httpOnlyX-Powered-By: Express解决方法 试试吧!
axios.get('your_url',{withCredentials: true}); //for GETaxios.post('your_url',data,{withCredentials: true}); //for POSTaxios.put('your_url',{withCredentials: true}); //for PUTaxios.delete('your_url',{withCredentials: true}); //for Delete 有关axios docs的更多信息:
“withCredentials指示是否应使用凭据进行跨站点访问控制请求” – https://github.com/axios/axios
有关withCredentials的更多细节:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
总结以上是内存溢出为你收集整理的express – Axios是否支持Set-Cookie?是否可以通过Axios HTTP请求进行身份验证?全部内容,希望文章能够帮你解决express – Axios是否支持Set-Cookie?是否可以通过Axios HTTP请求进行身份验证?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)