javascript - Cannot see my image because = CORB blocked cross-origin response - Stack Overflow

Hi i have a little problem, i use the GIPHY-api to get GIFS (obviously) and when i get the url of the G

Hi i have a little problem, i use the GIPHY-api to get GIFS (obviously) and when i get the url of the Gifs i need, i put them into my img src element. But CORB seems blocking the url for some reason

when i console.log the data.data[0].url i get this url =

here's the code :

function verwerkData(data) {
    gifContainer.innerHTML += `<img src="${data.data[0].url}" title="${data.data[0].title}"/>`;
}

The error = Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type text/html. See for more details.

Hi i have a little problem, i use the GIPHY-api to get GIFS (obviously) and when i get the url of the Gifs i need, i put them into my img src element. But CORB seems blocking the url for some reason

when i console.log the data.data[0].url i get this url = https://giphy./gifs/soulpancake-funny-kid-president-kidpresident-rgk1DxSugZDFu

here's the code :

function verwerkData(data) {
    gifContainer.innerHTML += `<img src="${data.data[0].url}" title="${data.data[0].title}"/>`;
}

The error = Cross-Origin Read Blocking (CORB) blocked cross-origin response https://giphy./gifs/soulpancake-funny-kid-president-kidpresident-rgk1DxSugZDFu with MIME type text/html. See https://www.chromestatus./feature/5629709824032768 for more details.

Share Improve this question asked Jun 10, 2021 at 15:29 frzfrz 211 gold badge1 silver badge2 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1

As Quentin mentioned it before, you have to find the image URL, not the page URL containing the image URL. You have two options. First, go by yourself, if it's not a dynamic web page, on the Giphy page, and search by yourself the image : https://i.sstatic/hx8SN.gif.

Else, using XHR or a backend request, perform a regex on the response content to extract the image. For the example :

const regex = /https:\/\/.*giphy.*\/media\/\w+\/giphy.gif\?cid=[a-f0-9]+&rid=giphy\.gif&ct=g/gi

The src attribute for an <img> has to contain the URL to an image

It doesn't make sense to put the URL to an HTML document there.

The error message essentially says "This is an HTML document, that can't be right, I'm blocking it".

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745287160a4620632.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信