bzarras / newsapi

A promise-based node interface for NewsAPI
MIT License
144 stars 39 forks source link

CORS #26

Closed DiegoVallejoDev closed 4 years ago

DiegoVallejoDev commented 4 years ago

I was having problems with and had to rebase


Added this to default request options, this might enable CORS in most enviroments

const reqOptions = { 'mode': 'cors', headers: { 'Access-Control-Allow-Origin': '*' } };

Also you can now set a CORS proxy url in an options parameter if above option is not working

Example:

const NewsAPI = require('newsapi');
const newsapi = new NewsAPI('YOUR_API_KEY', { corsProxyUrl: 'https://cors-anywhere.herokuapp.com/' });
```Added this to default request options, this might enable CORS in most enviroments
```js
const reqOptions = { 'mode': 'cors', headers: { 'Access-Control-Allow-Origin': '*' } };

Also you can now set a CORS proxy url in an options parameter if above option is not working

Example:

const NewsAPI = require('newsapi');
const newsapi = new NewsAPI('YOUR_API_KEY', { corsProxyUrl: 'https://cors-anywhere.herokuapp.com/' });
DiegoVallejoDev commented 4 years ago

CI automated tests fail because there's no API key in this repo, you can add a secret key on the reposettings

bzarras commented 4 years ago

Hmm, I already added the secret key, it seems to have worked for other changes that I recently pushed up

bzarras commented 4 years ago

Ah, this is why it's failing: image