fetch('https://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world')
.then(resp => resp.json())
.then(json => console.log(json))
我用 fetch
api 尝试从我的 gh-pages 获取 json 数据 (gh-pages Access-Control-Allow-Origi
的 为 *
)
但是我得到的是这个
然后我检查了一下 Chrome devtool 的 Network
我的 HTTPS 请求被浏览器取消,并且该次请求被视作一次 HTTP 请求
为什么会这样,怎么处理这种情况
你fetch的这个地址虽然是https的,但是里面是301跳转,又跳回http了。
不仅如此,尝试再去请求这个http地址,又会跳转到https:
你的gh-pages有问题。