CORS (Cross-Origin Resource Sharing) ਇੱਕ ਬ੍ਰਾਊਜ਼ਰ ਸੁਰੱਖਿਆ ਵਿਧੀ ਹੈ ਜੋ ਨਿਯੰਤ੍ਰਿਤ ਕਰਦੀ ਹੈ ਕਿ ਇੱਕ ਮੂਲ ਤੋਂ ਵੈੱਬ ਪੰਨਾ ਇੱਕ ਵੱਖ ਮੂਲ 'ਤੇ ਸਰਵਰ ਨੂੰ ਬੇਨਤੀਆਂ ਕਰ ਸਕਦਾ ਹੈ ਜਾਂ ਨਹੀਂ। ਡਿਫ਼ਾਲਟ ਦੇ ਅਨੁਸਾਰ, ਬ੍ਰਾਊਜ਼ਰ ਕ੍ਰਾਸ-ਓਰੀਜਿਨ ਬੇਨਤੀਆਂ ਨੂੰ ਰੋਕਦੇ ਹਨ; ਸਰਵਰ ਨੂੰ ਜਵਾਬ ਹੈਡਰ ਦੁਆਰਾ ਸਪੱਸ਼ਟ ਤੌਰ 'ਤੇ ਉਨ੍ਹਾਂ ਨੂੰ ਆਗਿਆ ਦੇਣੀ ਚਾਹੀਦੀ ਹੈ।
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.
