简体   繁体   English

在 react js 中使用新闻 api 时加载资源失败:net::ERR_SSL_PROTOCOL_ERROR

[英]Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR while using news api in react js

I am working on a reactjs website.我正在一个 reactjs 网站上工作。 The website is basically a news website in which i have used news Api to fetch data but in news api data there is a image url "https://cdn.siasat.com/wp-content/uploads/2021/07/Antarctica.jpg" that is not working .I want to replace it with an image from my folder .I have written a code for this purpose that is successfully changing it to img.jpg image of my folder but it is not showing in my localhost site.该网站基本上是一个新闻网站,我在其中使用新闻 Api 来获取数据,但在新闻 api 数据中有一个图像 url “https://cdn.siasat.com/wp-content/uploads/2021/07/Antarctica. jpg” 不起作用。我想用我文件夹中的图像替换它。我为此编写了一个代码,成功地将其更改为我的文件夹的 img.jpg 图像,但它没有显示在我的本地主机站点中。

This is the logic i have written to change emptyimage url .
export class Newsitem extends Component {
  render() {
    //   this is called destructuring in js meas you can fetch description and title from single prop
      let {title,description,imageurl,newsurl}=this.props
    return (
      <div className='my-3'>
<div className="card" style={{width: "18rem"}}>
<img src={imageurl==="https://cdn.siasat.com/wp-content/uploads/2021/07/Antarctica.jpg"?"img.jpg":imageurl}className="card-img-top" alt="..."/>
<div className="card-body">
<h5 className="card-title">{title}...</h5>
<p className="card-text">{description}...</p>
<a href={newsurl} target="_blank" className="btn btn-sm btn-primary">Read more...</a>
</div>
</div>
        
      </div>
    )
  }
}

This is the code after running and inspecting it in console :
<img src="img.jpg" class="card-img-top" alt="...">

This code has changed the url to img.jpg but i don't understand why it is not displaying in my website.此代码已将 url 更改为 img.jpg 但我不明白为什么它没有显示在我的网站上。 My console is showing this "Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR cdn.siasat.com/wp-content/uploads/2021/07/Antarctica.jpg:1".I have already change this url to img.jpg我的控制台显示“加载资源失败:net::ERR_SSL_PROTOCOL_ERROR cdn.siasat.com/wp-content/uploads/2021/07/Antarctica.jpg:1”。我已经将此网址更改为 img.jpg

This may not answer your specific question but it may help others who get the same error.这可能无法回答您的具体问题,但它可能会帮助其他遇到相同错误的人。 I got the Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR error message on a web application I developed which is hosted in Azure.我在 Azure 中开发的 Web 应用程序上收到Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR错误消息。 There are images on the page that are hosted on a server with a virtual directory.页面上有托管在具有虚拟目录的服务器上的图像。 The URL used the HTTP protocol and had a port number in the URL, like this:该 URL 使用 HTTP 协议,并且在 URL 中有一个端口号,如下所示:

http://remote1.nikecaps.com:12345/ipad_images/Style Item/SPORT-CLIMB.jpg

This link worked when we navigated to it locally, outside of the new web app.当我们在本地导航到它时,这个链接有效,在新的网络应用程序之外。 However, in the Azure web app, we got the error.但是,在 Azure Web 应用程序中,我们收到了错误。

Originally, the browser complained about having to serve images with URLs that use HTTP on a site that uses HTTPS.最初,浏览器抱怨必须在使用 HTTPS 的站点上提供带有使用 HTTP 的 URL 的图像。 So we changed the image URLs to use HTTPS, but then we got this specific SSL protocol error you are receiving now.因此,我们将图像 URL 更改为使用 HTTPS,但随后我们收到了您现在收到的特定 SSL 协议错误。

Our fix was to remove the port number, now that the URL is HTTPS.我们的修复是删除端口号,现在 URL 是 HTTPS。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载资源:net::ERR_SSL_PROTOCOL_ERROR - JavaScript 到 Spring Z50780F47F6839D47D60BC4555EE00C3F3 A164747CACED10888008DD81C2F4D7987 - Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR - JavaScript to Spring REST API Socket.IO 加载资源失败:net::ERR_SSL_PROTOCOL_ERROR - Socket.IO Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR socket.io 错误网络::ERR_SSL_PROTOCOL_ERROR - socket.io error net::ERR_SSL_PROTOCOL_ERROR 如何修复由我的 js 代码引起的 net::ERR_SSL_PROTOCOL_ERROR - How do I fix net::ERR_SSL_PROTOCOL_ERROR caused by my js code 访问不同端口时,js fetch 失败并出现 net::ERR_SSL_PROTOCOL_ERROR - js fetch fails with net::ERR_SSL_PROTOCOL_ERROR when accessing different ports 如何处理net :: ERR_SSL_PROTOCOL_ERROR? - How to deal with net::ERR_SSL_PROTOCOL_ERROR? PHP Websocket 错误:net::ERR_SSL_PROTOCOL_ERROR 使用 cloudflare - PHP Websocket ERROR: net::ERR_SSL_PROTOCOL_ERROR using cloudflare Wordpress - 错误 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL 协议错误 - Wordpress - Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error 具有SSL的Azure辅助角色上的Node.js导致ERR_SSL_PROTOCOL_ERROR - Node.js on Azure Worker Role w/ SSL results in ERR_SSL_PROTOCOL_ERROR 连接建立错误:尝试建立并连接到Websocket服务器时,抛出net :: ERR_SSL_PROTOCOL_ERROR - Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM