5

I have an image on imgur. this image is displaying on any website except on localhost.

What might be the problem?

<img class="cover" src="https://i.stack.imgur.com/wqYLI.jpg" alt="">

Error: GET https://i.stack.imgur.com/wqYLI.jpg 403 (Forbidden)

Elyor
  • 5,396
  • 8
  • 48
  • 76
  • 403 forbidden, means you don't have access to this source. Mostly deep/hotlinking protection. What happend if you put this code on an online environment? – node_modules May 11 '17 at 10:28

3 Answers3

5

Strangely, imgur is restricting to access the image directly from localhost. However if you access your localhost using IP address, you are able to see the image.

Example:

http://localhost/site (not allowed)

http://192.168.0.2/site (allowed)

This is not only for this image, but also any imgur image.

Elyor
  • 5,396
  • 8
  • 48
  • 76
0

They block 127.0.0.1 origin for some reason. To solve this, I added a new line to my /etc/hosts file:

127.0.0.1 vnbrs.localhost

And accessing vnbrs.localhost:4001 (the port I was running my web server), it worked!

Please note that you have to use the .localhost TLD.

vinibrsl
  • 6,563
  • 4
  • 31
  • 44
0

This isn't really a solution to your live-server issue however:

Using Visual Studio Code editor, having tried following extentions:

  • Live-server | Imgur.com not allowing the image from the src.
  • preview on web server | Imgur.com is allowing the image from the src.

So if all you are interested in is figuring out how it looks and making adjustments I suggest just using preview on web server extentions.

c0d3r4ng0
  • 3
  • 2