CORS (Cross-Origin Resource Sharing) એ બ્રાઉজર સુરક્ષા મેકેનિઝમ છે જે નિયંત્રણ કરે છે કે એક origin પર વેબ પૃષ્ઠ અલગ origin પર સર્વર માટે વિનંતીઓ કરી શકે છે કે કેમ. ડિફૉલ્ટ રીતે, બ્રાઉજર ક્રોસ-origin વિનંતીઓને અવરોધિત કરે છે; સર્વરે તેમને રেસપોન્સ હેડર દ્વારા સ્પષ્ટપણે અનુમતિ આપવી જોઈએ.
same-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.
