zoukankan      html  css  js  c++  java
  • 前端项目跨域请求报错

    在开发VUE前端项目访问服务端的接口的时候报错:

    Access to fetch at

    'https://xxx.xxx.com/xxx/xxx/xxx?param=xxx' from origin 'http://xxx.xxx.com:xxx'

    has been blocked by CORS policy:

    Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

    大致意思是:是一个跨域请求我的没有访问该地址的权限(接口服务器采用的是PHP编写)

    解决方案:

    header('Access-Control-Allow-Origin: *');
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
    header('Access-Control-Allow-Methods: GET, POST, PUT');

    具体请参考以下网址:

    https://www.cnblogs.com/jasonLiu2018/p/10939304.html

    https://blog.csdn.net/abs1004/article/details/76895652

  • 相关阅读:
    Flutter 导航栏上添加搜索按钮
    tabController保活
    nav 选项卡
    flutter 毛玻璃
    [题解]CodeForces878 D
    [题解]CodeForces878C Tournament
    [题解]NOIP2012
    bzoj1070题解
    bzoj1061题解
    bzoj1059题解
  • 原文地址:https://www.cnblogs.com/gougou1981/p/14309216.html
Copyright © 2011-2022 走看看