3 Ways to Fix the CORS Error — and How the Access-Control-Allow-Origin Header Works

The Cors Error

Fix one: install the Allow-Control-Allow-Origin plugin

But the plugin fix is deceiving

Why was the CORS error there in the first place?

How does the same-origin policy work under the hood?

Origin: http://localhost:3000
Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Allow-Origin: *

Did the plugin “fix” it?

Fix two: send your request to a proxy

Fix three: build your own proxy

If you want to see this in action, head to the source code for the above, along with relevant steps in the README: https://github.com/15Dkatz/beat-cors-server


Connect with David

David Katz is a software engineer and course creator, with 16 courses published so far. Check them out at https://davidtkatz.com/