简体   繁体   中英

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:

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:
在此处输入图片说明

What I'm missing? this is because access-control-allow-credentials set to 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 ,

but on the right side ,the curl example use https://api.imgur.com/3/image has Access-Control-Allow-Origin header

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM