gpt4 book ai didi

cors - 调用axios.get时发生CORS错误

转载 作者:行者123 更新时间:2023-12-03 12:10:37 25 4
gpt4 key购买 nike

我正在使用axios在我的redux action.js文件中进行axios.get调用。
在我的组件中,此操作是在表单提交时执行的。

我在控制台中收到状态200,但未收到任何响应。
我收到以下错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:\\\\localhost:3000' is therefore not allowed access.
有人也遇到过这样的错误吗?请您分享如何解决此问题。

最佳答案

问题不在于axios。问题出在服务器上。提供数据时,必须在发送数据之前添加以下 header 。

访问控制允许来源
必须设置为
*

访问控制允许标题
必须设置为
来源,X-请求方式,内容类型,接受

关于cors - 调用axios.get时发生CORS错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35164116/

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