5
LeMeow
7y

Fetch API gives CORS error..

Then I use JQuery AJAX request and it works fine...? 😑

Can you even handle CORS requests with Fetch?
🤔

Comments
  • 0
    Does the resource set the http-cors-header correctly?
    From what i think jquery is using xmlhttprequest which wasn't intented for cors-headers, fetch should be different there
  • 1
    Fun fact:
    To enable cors in flash, website-admins had to put a crossdomain.xml in their root directory to tell flash what it was allowed to read.
    Good thing flash's dying.
  • 0
    Aye, get or post? Im struggling with fetch too, and the backend is fine so it must be the fetch api.
  • 0
    You could use the "no-cors" option of fetch but this way you won't be able to read the response.
    See: https://stackoverflow.com/a/...
Add Comment