Error 426 from newsapi.org once I deployed my site on Netlify
Asked Answered
L

5

5

While I was trying my project on localhost it was working fine, using https://cors-anywhere.herokuapp.com/ since I got the CORS problem. But once I deployed the site on Netlify, it gave me the error 426 (Upgrade Required), with or without using https://cors-anywhere.herokuapp.com/. These are the messages that appear on my console:

>Failed to load resource: the server responded with a status of 426 (Upgrade Required)

>Error: Request failed with status code 426
    at createError.js:16
    at settle.js:17
    at XMLHttpRequest.<anonymous> (xhr.js:61)

I have been searching and some people seem to have similar problem to this. I have seen solutions like having my own server to pass the requests, but I don't know how to do it and, correct me if I am wrong, wouldn't that be the same as using https://cors-anywhere.herokuapp.com/?

Leith answered 2/6, 2020 at 16:44 Comment(0)
O
10

Newsapi changed their pricing model.

You can't make requests from the browser anymore, you'll have to use a backend. I had the same problem and the easiest way around it was implementing a Node (Express) server.

Obbard answered 4/6, 2020 at 16:4 Comment(4)
Thanks, I won't be creating a Node server as I don't know how, but since It is a school proyect I will be able to get away showing it locally. Thanks for the suggestion thoLeith
i am having the same problem, how do i get started on building a node (Express) server? thx.Truculent
@Obbard Hi, how and where can I build Node Express server to get around the 426? Thanks.Truculent
youtube.com/watch?v=kJA9rDX7azM This tutorial was a good start for me. I'm not sure what you're using for a front end but I used React for my project and it showed how to connect them. It will teach you how to make requests from your front-end to the back-end, and from the back-end to your API.Obbard
R
1

I guess the free plan simply is not longer available in production.

"Requests from the browser are not allowed on the Developer plan, except from localhost."

Here's the updated plan page.. https://newsapi.org/pricing

Rollmop answered 4/6, 2020 at 13:57 Comment(1)
thanks, I guess I will have to show my project locallyLeith
K
1

Actually newsapi.org api in developer plan is no more working in production. because in developer plan CORS is only enabled for localhost.

Developer Plan $0 CORS enabled for localhost. https://newsapi.org/pricing

but if you want to fetch news in production then there is a alternative for this which have 1000 request per month free works in production also . https://newsapi.in/

Newsapi.in this website provide api that have cors enabled for all origins.

Enjoy...

Kimberykimble answered 29/1, 2022 at 4:45 Comment(0)
N
1

As others have mentioned, Newsapi no longer allows you to make requests from the browser.

newscatcher has a no-card free tier that allows for 10,000 requests. On top of that, depending on your use case you can even mail them to increase the limits for a short span of time, or to add extra data points.

Neil answered 31/1, 2022 at 5:24 Comment(0)
M
0

For future nerds:

I would also like to add that it is possible to connect Zapier to your application and News API is fully supported that way, but as others have said, no more fetch-ing or async-ing news.

Moonseed answered 21/4, 2024 at 0:18 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.