zoukankan      html  css  js  c++  java
  • Angular:Invalid Host/Origin header问题解决方案

    复制:https://blog.csdn.net/qq_36451496/article/details/99712925

    最近在Chrome浏览器调试的时候遇到一个问题,浏览器的控制台一直报错 Invalid Host/Origin header,在百度上看到也有人遇到过这个问题,参考链接:https://blog.csdn.net/u013243347/article/details/85223016

    作者给出的解释是这是webpack本身出于安全考虑,因为不检查主机的应用程序容易受到DNS重新绑定攻击。但是,在我们的开发环境下,可以禁用掉disableHostCheck这一配置项。

    也给出了解决方案:在webpack.config.js配置文件中添加以配置——disableHostCheck:true

    但是我的这个项目用的是Angular6,项目里面没有这个webpack.config.js文件,这样的话我们需要在angular.json文件里面,修改一个builder名为@angular-devkit/build-angular:dev-server的配置,在它的options里面添加“disableHostCheck”:true

    附上我的angular.json的相关代码片段:

    1.  
      "serve": {
    2.  
      "builder": "@angular-devkit/build-angular:dev-server",
    3.  
      "options": {
    4.  
      "browserTarget": "angular-antd:build",
    5.  
      "disableHostCheck": true
    6.  
      },
    7.  
      "configurations": {
    8.  
      "production": {
    9.  
      "browserTarget": "angular-antd:build:production"
    10.  
      }
    11.  
      }
    12.  
      },
  • 相关阅读:
    [LeetCode]Reverse Linked List II
    [LeetCode]Move Zeroes
    Next Greater Element I
    Keyboard Row
    Number Complement
    SQL语句学习(二)
    SQL语句学习(一)
    jQuery学习(三)
    jQuery学习(二)
    JQuery学习(一)
  • 原文地址:https://www.cnblogs.com/xiaoruilin/p/14403477.html
Copyright © 2011-2022 走看看