gpt4 book ai didi

javascript - localhost - 仅协议(protocol)方案支持跨源请求?

转载 作者:行者123 更新时间:2023-11-29 16:38:58 25 4
gpt4 key购买 nike

我有以下功能:

this.Locations = axios.get('localhost:8081/fetchData?table=locations').then((res) => {                                         
return res
})

在我的 app.js 中,我设置了一个端点“/fetchData”,如果我只是在浏览器中执行,它就可以正常工作。

我为什么会收到此错误消息?

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

最佳答案

您需要指定一个方案,例如http://。将您的功能更改为:

this.Locations = axios.get('http://localhost:8081/fetchData?table=locations').then((res) => {                                         
return res
})

关于javascript - localhost - 仅协议(protocol)方案支持跨源请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48362921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com