Search code examples
javascriptcorsimgur

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: enter image description here

The request itself:
enter image description here

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


Solution

  • 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