gpt4 book ai didi

reactjs - 来自来源 'http://localhost:3000'的邮件已被CORS政策: No 'Access-Control-Allow-Origin' header is present on the requested resource阻止

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

我已经尝试解决这个问题超过一个星期了。我是新来的 meteor 。即使我不太懂英语,我也想自己学习。
但是我正在尝试访问一个获得此en entratrado的api,您应该输入如下消息

Access-Control-Allow-Origin: *

但我不知道怎么去哪里

也尝试把 {mode: 'no-cors'} fetch('http://sipla.cuci.udg.mx/sc/horariop.php?c=219359735&k=0d8ce4fab5f4df9ce711cae81e044e1a',{mode: 'no-cors'})对我无用
componentDidMount() {

fetch('http://sipla.cuci.udg.mx/sc/horariop.php?c=219359735&k=0d8ce4fab5f4df9ce711cae81e044e1a')

.then((response) => {
return response.json()
})
.then((dat) => {
this.setState( {datos1: dat })
})
}

最佳答案

假设您在尝试访问该URL时遇到CORS错误;您可以在URL上添加反向代理CORS前缀以进行调用以绕过该URL;

只需在URL前面加上“https://cors-anywhere.herokuapp.com/”,就不会出现跨源错误。

var url = 'https://cors-anywhere.herokuapp.com/http://sipla.cuci.udg.mx/sc/horariop.php?c=219359735&k=0d8ce4fab5f4df9ce711cae81e044e1a';
fetch(url, {
method: 'GET',
headers:{
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => res.json())
.then(response => console.log('Success:', response))
.catch(error => console.error('Error:', error));

关于reactjs - 来自来源 'http://localhost:3000'的邮件已被CORS政策: No 'Access-Control-Allow-Origin' header is present on the requested resource阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56781610/

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