duanli8577 2019-02-21 13:38
浏览 1497

cors(cors policy:对预检请求的响应未通过访问控制检查)角度7中的错误

Access to XMLHttpRequest at 'http://192.168.1.30/v1w/?tag=login' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

  • 写回答

1条回答 默认 最新

  • duancaishi1897 2019-02-22 04:41
    关注

    Here are possible solutions

    1. You need to add CORS headers at your PHP end. Solution is provided in another question CORS with php headers

    2. If you do not want to add CORS, which I recommend when for your production environment, you can setup a reverse proxy using nginx or httpd such that both your http-request and html files are served from same url base

    3. You can also temporarily disable CORS check on browser. Answered here: Does --disable-web-security work in Chrome anymore?

    4. You can also use chrome extension or firefox extension which can disable CORS check for certain domains. Example https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en-US

    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗