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. LFS7.10——构造临时Linux系统

    参考:LFS编译——准备Host系统 前言 在准备好Host环境后,接下来构造一个临时Linux系统.该系统包含****构建所需要的工具.构造临时Linux系统分两步: 构建一个宿主系统无关的新工具链 ...

  2. 让 Python 代码更易维护的七种武器——代码风格(pylint、Flake8、Isort、Autopep8、Yapf、Black)测试覆盖率(Coverage)CI(JK)

    让 Python 代码更易维护的七种武器 2018/09/29 · 基础知识 · 武器 原文出处: Jeff Triplett   译文出处:linux中国-Hank Chow    检查你的代码的质 ...

  3. Kotlin构造方法详解与初始化过程分析

    在上一次https://www.cnblogs.com/webor2006/p/11192025.html已经初识了Kolin的面向对象,先来回顾一下: 介绍了primary 构造方法,其特点回忆一下 ...

  4. machine learning (1)

    Machine learning (1)   机器学习的两种定义 the field of study that gives computers the ability to learn withou ...

  5. Oracle 数据库中的GROUP BY与HAVING

    一.GROUP BY GROUP BY语句用来与聚合函数(aggregate functions such as COUNT, SUM, AVG, MIN, or MAX.)联合使用来得到一个或多个列 ...

  6. Mac下安装SQLmap的安装

    1.cd /usr/bin/ 2.sudo git clone https://github.com/sqlmapproject/sqlmap.git sqlmap-dev3.重新打开terminal ...

  7. redis 缓存问题,转载:https://www.cnblogs.com/liangsonghua/p/www_liangsonghua_me_22.html

    缓存穿透: 缓存穿透是指查询一个一定不存在的数据,由于缓存是不命中时被动写的,并且处于容错考虑,如果从存储层查不到数据则不写入缓存,这将导致这个不存在的数据每次请求都要到存储层去查询,失去了缓存的意义 ...

  8. 使用lua脚本在nginx上进行灰度流量转发

    参考资料 idea+openresty+lua开发环境搭建 OpenResty最佳实践 灰度发布基于cookie分流 从请求中获取值 -- 从请求中获取请求头为 Sec-WebSocket-Proto ...

  9. 多线程实现的方式二实现Rannable

    package thread; class Thread2 implements Runnable{ private String name; public Thread2(String name) ...

  10. Hibernate的持久化对象

     Hibernate的持久化类 什么是持久化类        1. 持久化类:就是一个Java类(咱们编写的JavaBean),这个Java类与表建立了映射关系就可以成为是持久化类.        * ...