antdesignpro开发碰到的跨域问题

跨域问题

为了让admin管理系统适应手机版,决定对首页及各个功能页进行升级。以前用admin antd design作为脚手架进行开发发现对手机版支持不好。这次用ant design的pro版进行开发,从新搭建前端开发框架。

成都创新互联成都网站建设定制网站制作,是成都营销推广公司,为玻璃隔断提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站设计热线:13518219792

之前框架用axios作为请求网络的基础组件,碰到了一些跨域问题,在我的另一篇里面介绍了解决方案。这次用的是dva/fetch里面的fetch请求网络数据,碰到新的跨域问题如下:

The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8000' is therefore not allowed access.

ant design pro开发碰到的跨域问题

此时server设置是这样

    header('Access-Control-Allow-Origin: *');

修改之后:

   header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);

又出现了新的问题:

ant design pro开发碰到的跨域问题

The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:8000' is therefore not allowed access.

于是在server端又增加了:

    header('Access-Control-Allow-Credentials: true');

问题得到解决。

新闻名称:antdesignpro开发碰到的跨域问题
转载源于:https://www.cdcxhl.com/article6/jdoeig.html

成都网站建设公司_创新互联,为您提供手机网站建设电子商务服务器托管网站制作网站营销静态网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网页设计公司