Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

Create-react-app proxy跨域设置问题,在线求解

$
0
0

在开发环境下,在package.json中直接设置"proxy":“https://news-at.zhihu.com”,在项目中通过:

fetch('/api/4/news/latest').then(res=>{
	return res.json();
}).then(data=>{
	console.log(data);
})

是可以成功获取数据的, 但是在package.json如下设置:

"proxy": {
		"/api": {
				"target": "https://news-at.zhihu.com",
				"secure":false
		}
}

就会报错,如下: DingTalk20180228155632.png在线等大神回复


Viewing all articles
Browse latest Browse all 14821

Trending Articles