https://stackoverflow.com/questions/7210507/ajax-post-error-refused-to-set-unsafe-header-connection/7210840

Remove these two lines:

xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

XMLHttpRequest isn't allowed to set these headers, they are being set automatically by the browser. The reason is that by manipulating these headers you might be able to trick the server into accepting a second request through the same connection, one that wouldn't go through the usual security checks - that would be a security vulnerability in the browser.

// request interceptor
service.interceptors.request.use(
    config => {
        // do something before request is sent
        // console.log(store.getters.token)
        config.headers['Access-Control-Allow-Origin'] = '*'
        config.headers['cache-control'] = 'max-age=1,s-maxage=1'
        config.headers['Cookie'] = 'noBy-interceptors.request'

xhr.js:108 Refused to set unsafe header "Cookie"的更多相关文章

  1. 从XMLHttpRequest请求响应里getResponseHeader(header)报错:Refused to get unsafe header "**" 问题解决

    问题产生原因: 原因1:W3C的 xhr 标准中做了限制,规定客户端无法获取 response 中的 Set-Cookie.Set-Cookie2这2个字段,无论是同域还是跨域请求: 原因2:W3C ...

  2. Refused to set unsafe header "Connection"

    参考 http://stackoverflow.com/questions/7210507/ajax-post-error-refused-to-set-unsafe-header-connectio ...

  3. Refused to set unsafe header

    Refused to set unsafe header Refused to set unsafe header "Host"waitServerDeal @ tGet.html ...

  4. Chrome浏览器控制台报Refused to get unsafe header "XXX"的错误

    最近在调试后端下载的接口时在浏览器的控制台中发现了红色的错误信息,例如Refused to get unsafe header "XXX":前端是采用XMLHttpRequest对 ...

  5. SpringSession header/cookie/attribute存放 session id

    SpringSession header/cookie/attribute存放 SessionID(死磕) 疯狂创客圈 Java 高并发[ 亿级流量聊天室实战]实战系列 [博客园总入口 ] 架构师成长 ...

  6. js 忘记密码发送短信记录cookie

    <div class="forgetPwdBox" style="display:none"> <div class="forTit ...

  7. js ajax设置和获取自定义header信息的方法总结

    目录 1.js ajax 设置自定义header 1.1 方法一: 1.2 方法二: 2.js ajax 获取请求返回的response的header信息 3.js ajax 跨域请求的情况下获取自定 ...

  8. ajax请求node.js接口时出现 No 'Access-Control-Allow-Origin' header is present on the requested resource错误

    ajax请求node.js接口出现了如下的错误: XMLHttpRequest cannot load http://xxx.xxx.xx.xx:8888/getTem?cityId=110105&a ...

  9. node.js平台下Express的session与cookie模块包的配置

    首先下载两个模块包 session模块包:用于保持登录状态或保持会话状态等. npm install express-session --save-dev cookie模块包:用于解析cookie. ...

随机推荐

  1. 从SVN资源库下载项目

    1.这个操作和新建Import导入项目差不多,先左上角File--Import--SVN(这个在弹出窗口的下面)平时都是选最上面的General,再点从SVN检出项目. 2.创建新的资源库位置,然后输 ...

  2. MySQL批量修改相同后缀表名

    执行步骤 1.用concat批量生成修改表名的语句 SELECT CONCAT( 'ALTER TABLE ', table_name, ' RENAME TO ', ,locate('_postfi ...

  3. 小程序框架之视图层 View~事件系统~WXS响应事件

    WXS响应事件 基础库 2.4.4 开始支持,低版本需做兼容处理. 背景 有频繁用户交互的效果在小程序上表现是比较卡顿的,例如页面有 2 个元素 A 和 B,用户在 A 上做 touchmove 手势 ...

  4. java.lang.RuntimeException: org.springframework.dao.DuplicateKeyException:

    java.lang.RuntimeException: org.springframework.dao.DuplicateKeyException: ### Error updating databa ...

  5. asp、aspx、php、jsp万能密码大全【笔记】

    asp aspx万能密码 1:"or "a"="a 2: ')or('a'='a 3:or 1=1-- 4:'or 1=1-- 5:a'or' 1=1-- 6: ...

  6. .net框架-栈(Stack)

    栈(Stack) 栈代表一个后进先出的集合 栈元素为Object类型 .net框架提供Stack<T>泛型栈类 压栈(Push)和出栈(Pop)是栈的基本操作,压栈入栈顶,出栈也出栈顶. ...

  7. C++template基础

    函数模板 类模板 参数魔法 模板与友元

  8. win10 安装python模块objgraph+PyCharm环境配置

    1. 打开win10的命令行窗口 2.在命令行中输入python -m pip install objgraph,系统会自动帮忙安装 3.安装完成后,可以用命令python -m pip list查看 ...

  9. 【二分答案】Expanding Rods POJ 1905

    题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...

  10. LightOJ - 1246 - Colorful Board(DP)

    链接: https://vjudge.net/problem/LightOJ-1246 题意: You are given a rectangular board. You are asked to ...