Getting error 426 from newsapi.org

Hello, I am using VueJS and fetch data from newsAPI.org for my project.

In localhost it was all working fine, but then after deploying the site to Netlify I got a “Failed to load resource: the server responded with a status of 426 (Upgrade Required)” error. I have been searching for some explanation as the error is not very helpful but I haven’t found anything.

I have to mention that in localhsot I had to use https://cors-anywhere.herokuapp.com/, but after deploying to Netlify I have had the same error with and without the proxy.

I am also new to Netlify, I hope you can help me.

Hey @Epsiloth,
On https://cors-anywhere.herokuapp.com/, it says “If the protocol is omitted, it defaults to http (https if port 443 is specified).” - this might explain the 426 upgrade required error. Can you let us know if you have the protocol included in your api request, and if changing it/making sure it’s “https” fixes things? If not, please share your Netlify URL so we can dig in further!

In the end it seems like the problem was with the API I was trying to request from, that recently changed liberties from the free version. Thanks anyway

Hi there,

I’m encountering the exact same problem, how did you fix the issue? What is strange is that when following the URL, i can see the appropriate response, but in my application I get a 426 error…?

Thanks

Yeah, specifically with newsapi.org, seems like since 22 May 2020 they changed the liberties of the free developer keys and now they reject any request using that key that is not coming from localhost. You need to buy one of the keys intended for projects on production.

As for me, since it was just a school project I just put my site on production and deployed locally. As long as the page is in localhost the free version still works.

Some people recommend passing the requests through your backend/server but I don’t know how that works.

3 Likes

Yes, I came across the same 426 error using newsapi.org for a project of mine. Thank you @Epsiloth for sharing this information for the change in May. I was using the API around 1 week before this change and did not notice this error until now. I was successful in switching the API to https://gnews.io/ to retrieve the same information. GNews has a limit of 10 articles per search and 100 API calls per day. Not bad for a free service.

How can we pass the requests through the backend server? I would like to learn that… Ive been googling, but need a little help in the right direction… any help would be greatly apperciated.