由于Cors,无法将图片上传到imgur [英] Upload image to imgur failed because of cors

查看:127
本文介绍了由于Cors,无法将图片上传到imgur的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用js(浏览器)将图像上传到imgur并收到CORS错误:

I'm trying to upload an image to imgur with js (browser) and get a CORS error:

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:

请求本身:

The request itself:

我丢失了什么?这是因为 access-control-allow-credentials 设置为 true

What I'm missing? this is because access-control-allow-credentials set to true?

推荐答案

问题出在其API文档:\
URL为: https://api.imgur.com/3 / image 而不是 https://api.imgur.com/3/upload ,如此处所述: https://apidocs.imgur.com/#c85c9dfc-7487-4de2-9ecd-66f727cf3139

The problem was with their API Docs :\ The URL is: https://api.imgur.com/3/image and not https://api.imgur.com/3/upload as said here: https://apidocs.imgur.com/#c85c9dfc-7487-4de2-9ecd-66f727cf3139

这篇关于由于Cors,无法将图片上传到imgur的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆