CORS (Cross-Origin Resource Sharing) är en webbläsarens säkerhetsmekanism som styr om en webbsida från en origin kan göra förfrågningar till en server på en annan origin. Som standard blockerar webbläsare cross-origin-förfrågningar; servern måste uttryckligt tillåta dem via svarsheaders.
Same-origin-principen och problemet
Origin = scheme + host + port. These are DIFFERENT origins:
https://app.example.com → https://api.example.com (different host)
http://localhost:3000 → http://localhost:4000 (different port)
Browser blocks the cross-origin request UNLESS the server sends CORS headers allowing it.
