[英]Upload image to imgur failed because of cors
I'm trying to upload an image to imgur with js (browser) and get a CORS error:我正在尝试使用 js(浏览器)将图像上传到 imgur 并收到 CORS 错误:
Access to XMLHttpRequest at 'https://api.imgur.com/3/upload' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
But preflight request contains Access-Control-Allow-Origin
header:但预检请求包含
Access-Control-Allow-Origin
标头:
What I'm missing?我缺少什么? this is because
access-control-allow-credentials
set to true
?这是因为
access-control-allow-credentials
设置为true
?
问题是与他们的API文档:\\的网址是: https://api.imgur.com/3/image
而不是https://api.imgur.com/3/upload
为这里说: https://开头apidocs .imgur.com /#c85c9dfc-7487-4de2-9ecd-66f727cf3139
according todoc https://api.imgur.com/3/upload
doesnt have necessary header ,根据文档
https://api.imgur.com/3/upload
没有必要的标题,
but on the right side ,the curl example use https://api.imgur.com/3/image
has Access-Control-Allow-Origin
header但在右侧,curl 示例使用
https://api.imgur.com/3/image
具有Access-Control-Allow-Origin
标头
and somehow they will check your referer, which means if you are in develop mode like webpack dev mode use localhost:8000
it will always return 429 too many request
exception并且他们会以某种方式检查您的引用者,这意味着如果您处于开发模式,如 webpack 开发模式使用
localhost:8000
它将始终返回 429 too many request
异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.