问题描述
我一直在制作一个React应用,最近每次尝试像这样从imgur访问图像
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`
});
它正在这样渲染
<img src={this.state.imgUrl}/>
但是我一直禁止403,但是当我使用邮递员或在浏览器中访问它时就可以了.我还通过传递相册网址(如
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
并从那里获取所有图像以显示在应用程序中(我收到403错误)
and getting all the images from there to be displayed in the app (where i get 403 errors)
我不确定我在哪里可能做错了什么,我还尝试获取API授权的新客户端ID,但仍无法正常工作.有人有建议吗?
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?
推荐答案
Imgur的CDN似乎限制了对来自 127.0.0.1
引用者的图像的访问.已向他们报告这是一个问题(服务器配置的问题).
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).
同时尝试将您的开发服务器主机从 127.0.0.1
更改为 localhost
或您的真实IP地址.
Meanwhile try to change your dev server host from 127.0.0.1
to localhost
or maybe your real IP address.
这篇关于Imgur图片返回403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!