javascriptreactjsimgur

Imgur images returning 403


I've been making a react app and recently whenever I try to access images from imgur like so

this.setState({
  imgUrl: `https://i.imgur.com/${this.props.image.id}b.png`,
  imgBigUrl: `https://i.imgur.com/${this.props.image.id}l.png`
});

And it's being rendered like this

<img src={this.state.imgUrl}/>

But I keep getting 403 forbidden, but when I use postman or visit it in the browser it's fine. I'm also accessing the API by passing in an album url like

https://imgur.com/gallery/zrUFj

and getting all the images from there to be displayed in the app (where i get 403 errors)

I'm unsure where I could be have done something wrong, I've also tried getting a new client ID for the API authorization, still hasn't worked. Anyone have any suggestions?


Solution

  • Imgur's CDN seems to restrict access to images from a 127.0.0.1 referer. This has been reported to them as an issue (matter of server configuration).

    Meanwhile try to change your dev server host from 127.0.0.1 to localhost or maybe your real IP address.