What is CORS?
CORS is a browser rule that decides whether a web page may read responses from a different website’s server.
Your browser blocks a script on one origin from reading data from another unless the other server sends the right Access-Control-Allow-Origin header. It is a protection for users, not a server-side firewall.
A CORS error in the console usually means the server needs to allow your origin, not that your code is broken.