我正在学习vue,并且我正在用API调用来测试本地django服务器上的axios。因此,我遇到了CORS错误。我已经知道CORS是如何工作的,为什么它会阻塞我的呼叫,但是当我试图向这个假API发送一个电话进行测试时,它是完美无缺的。cors是怎么允许的?
下面是一个示例代码:
axios.get('https://localhost:8000/api/posts')
.then( () => console.log('Local server working :)'))
axios.get('https://jsonplaceholder.typicode.com/todos')
.then( () => console.log('Fake api working :)'))结果:

发布于 2021-03-24 12:03:17
服务器使用CORS相关的标头进行应答。

https://stackoverflow.com/questions/66780143
复制相似问题