Elyor
Elyor

Reputation: 5532

Imgur image not showing on localhost

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.sstatic.net/wqYLI.jpg" alt="">

Error: GET https://i.sstatic.net/wqYLI.jpg 403 (Forbidden)

Upvotes: 6

Views: 3884

Answers (3)

c0d3r4ng0
c0d3r4ng0

Reputation: 3

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.

Upvotes: 0

justapilgrim
justapilgrim

Reputation: 6882

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.

Upvotes: 0

Elyor
Elyor

Reputation: 5532

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.

Upvotes: 6

Related Questions