I've tried to solve this problem for more than a week. I'm new to this meteor. I'm trying to learn by myself even because I do not know English very well.
but I'm trying to access an api that I get this eh encotrado that you should put a message like
Access-Control-Allow-Origin: *
but I do not know how and where
also try to put {mode: 'no-cors'}
fetch('http://sipla.cuci.udg.mx/sc/horariop.php?c=219359735&k=0d8ce4fab5f4df9ce711cae81e044e1a',{mode: 'no-cors'})
no work for me
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 })
})
}
To allow any site to make CORS requests without using the * wildcard (for example, to enable credentials), your server must read the value of the request's Origin header and use that value to set Access-Control-Allow-Origin , and must also set a Vary: Origin header to indicate that some headers are being set ...
1. Use the proxy setting in Create React App. "proxy": "https://cat-fact.herokuapp.com/", Now when you make an API request to https://localhost:3000/api/facts Create React App will proxy the API request to https://cat-fact.herokuapp.com/facts and the CORS error will be resolved.
Use a Chrome extension to add Access-Control-Allow-Origin header into every response. To find one of them, just head over to Chrome Webstore and type in "CORS", dozens will show up in the search result. Or you can install CORS Helper, CORS Unblock or dyna CORS right away.
Assuming you're getting a CORS error when trying to hit that URL; you can add reverse-proxy CORS prefix to the URL to make your call to bypass it;
Just prepend 'https://cors-anywhere.herokuapp.com/' to the URL and you shouldn't get that cross origin error;
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With