美文网首页
跨域请求结果中header的权限控制Access-Control

跨域请求结果中header的权限控制Access-Control

作者: 已然之伤 | 来源:发表于2018-05-16 23:04 被阅读0次

    ionic项目研究登录认证,验证登录成功时服务端要将token放入response的header中,但页面无法获取,查了下是因为涉及跨域.
    stackflow中找到的答案:

    https://stackoverflow.com/questions/28805589/how-to-read-response-headers-in-angularjs

    大意为:在涉及跨域请求时,response中大部分header需要源服务端同意才能拿到,所以需要在response中增加一个如下header:

    Access-Control-Expose-Headers: content-type, cache, ...
    其中"content-type, cache, ..."为允许跨域访问的header的key,多个时用英文逗号隔开

    相关文章

      网友评论

          本文标题:跨域请求结果中header的权限控制Access-Control

          本文链接:https://www.haomeiwen.com/subject/rbxvdftx.html