Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cors hatası #12

Closed
zafer06 opened this issue Mar 19, 2020 · 2 comments
Closed

cors hatası #12

zafer06 opened this issue Mar 19, 2020 · 2 comments

Comments

@zafer06
Copy link

zafer06 commented Mar 19, 2020

axios veya fetch api ile "https://il-ilce-rest-api.herokuapp.com/v1/cities" adresinden veri almaya çalıştığımda aşağıdaki hatayı alıyorum.

Access to fetch at 'https://il-ilce-rest-api.herokuapp.com/v1/cities' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

@Pasinli
Copy link

Pasinli commented Mar 20, 2020

var proxyUrl = 'https://cors-anywhere.herokuapp.com/', targetUrl = 'https://il-ilce-rest-api.herokuapp.com/v1/cities' fetch(proxyUrl + targetUrl) .then(blob => blob.json()) .then(data => { return data; }) .catch(e => { return e; });

@zafer06
Copy link
Author

zafer06 commented Mar 21, 2020

Teşekkürler @Pasinli gönderdiğin kodlar işe yaradı. Ancak merak ediyorum bu soruna api tarafında bir çözüm bulunması daha doğru olmaz mıydı?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants