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

#1

在开发环境下,在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",
         "changeOrigin": true
     }
 }

就会报错,郁闷了:

换了个浏览器就ok了,目测可能是有缓存问题。。。。。。