Open Vinit-Dantkale opened 4 years ago
Hello! The same problem has not yet been resolved. You?
I had the same issue and fixed it by using a proxy server.
Thanks for brining this issue to my attention. If anyone has identified the problem, please feel free to submit a PR. I've been busy with other stuff and haven't been able to give this library much love recently
I've also been busy with my schedule. If anyone identifies the problem, please do tell, so it can be solved. Thank You for looking in 😄
Has there been any update on this?
I've made a fork for it
https://github.com/Destructor1702/newsapi
const NewsAPI = require('newsapi');
const newsapi = new NewsAPI('YOUR_API_KEY', { corsProxyUrl: 'https://cors-anywhere.herokuapp.com/' });
based on this thread
I also added the cors mode headers by default, so above option might not be needed
const reqOptions = { 'mode': 'cors', headers: { 'Access-Control-Allow-Origin': '*' } };
@Destructor1702 I have reviewed your PR and left a comment. I will merge and test when it is ready!
I have merged and released @Destructor1702 's PR to NPM as version 2.4.1. Please install the latest version and let me know if this resolves the issue
Access to fetch at 'https://newsapi.org/v2/top-headlines?country=in&category=general&sources=&q=&pageSize=20&page=1' from origin 'http://192.168.0.5:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I had seen CORS error also on the link where I've deployed my app. Could you let me know how to solve this?