为了让admin管理系统适应手机版,决定对首页及各个功能页进行升级。之前用admin antd design做为脚手架进行开发发现对手机版支持很差。此次用ant design的pro版进行开发,重新搭建前端开发框架。前端
以前框架用axios做为请求网络的基础组件,碰到了一些跨域问题,在个人另外一篇里面介绍了解决方案。此次用的是dva/fetch里面的fetch请求网络数据,碰到新的跨域问题以下:ios
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.
此时server设置是这样axios
header('Access-Control-Allow-Origin: *');
修改以后:跨域
header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);
又出现了新的问题:网络
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端又增长了:antd
header('Access-Control-Allow-Credentials: true');
问题获得解决。框架