我在Netlify上部署网站后,来自newsapi.org的错误426 [英] Error 426 from newsapi.org once I deployed my site on Netlify

查看:94
本文介绍了我在Netlify上部署网站后,来自newsapi.org的错误426的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地主机上尝试项目时,使用 https://cors-anywhere可以正常工作.herokuapp.com/,因为我遇到了CORS问题.但是,一旦在Netlify上部署了站点,无论是否使用 https,它都会给我错误426(需要升级).://cors-anywhere.herokuapp.com/.这些是出现在我的控制台上的消息:

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)

我一直在搜索,有些人似乎对此也有类似的问题.我见过类似的解决方案,例如拥有自己的服务器来传递请求,但是我不知道该怎么办,如果我错了,请更正我,这与使用 https://cors-anywhere.herokuapp.com/?

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/?

推荐答案

Newsapi更改了定价模式.

Newsapi changed their pricing model.

您无法再从浏览器发出请求,必须使用后端.我遇到了同样的问题,最简单的方法是实现节点(Express)服务器.

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.

这篇关于我在Netlify上部署网站后,来自newsapi.org的错误426的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆