1

Sometimes websites won't let you load images without a valid referrer. Take this as an example, it returns a forbidden error. In a similar question I have found this answer, that suggests doing something like this:

<img src onerror="fetch('https://i.pximg.net/img-original/img/2020/11/28/06/04/23/85949640_p0.png', {headers: {Referer: 'https://www.pixiv.net/en/'}}).then(r=>r.blob()).then(d=> this.src=window.URL.createObjectURL(d));" />

This however, still fails to load the image. Checking the code of some extensions that promise to fix this error by installing scripts shows that they're just changing the referral, and that this should get things working.

Swigg
  • 45
  • 5

1 Answers1

1

Sometimes websites won't let you load images without proper a referrer.

Yes. Plenty of websites do not want to pay to store images and transfer them over the network so that freeloaders can display them on their websites without shouldering the cost.

In a similar question I have found this answer, that suggests doing something like this

That fails for two reasons.

  1. It is a forbidden header. Browsers are designed to prevent your JavaScript from lying about where requests are being triggered from.
  2. Most sites hosting images don't grant permission, via CORS, to third-parties to read them with JS. They are even more unlikely to if they do referer checking to stop freeloading!

If a website doesn't want you displaying images they host, you need to respect that.

Pay for your own image hosting instead.

Don't copy the images from the third-party to your own site unless you are sure they aren't protected by copyright (or you have permission).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335