CORS (Cross-Origin Resource Sharing) هي آلية أمان في المتصفح تتحكم في ما إذا كانت صفحة ويب من origin واحد يمكنها إرسال طلبات إلى خادم على origin مختلف. بشكل افتراضي، يحجب المتصفح الطلبات عبر الـ origins؛ يجب على الخادم السماح بها صراحةً عبر رؤوس الاستجابة.
مبدأ نفس الـ Origin والمشكلة
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.
