CORS (Cross-Origin Resource Sharing) ਇੱਕ ਬ੍ਰਾਊਜ਼ਰ ਸੁਰੱਖਿਆ ਵਿਧੀ ਹੈ ਜੋ ਇਹ ਨਿਯੰਤ੍ਰਿਤ ਕਰਦੀ ਹੈ ਕਿ ਕੀ ਇੱਕ origin ਤੋਂ ਇੱਕ ਵੈੱਬ ਪੰਨਾ ਵਿਭਿੰਨ origin ਤੇ ਆਪਣੀ API ਨੂੰ ਕਾਲ ਕਰ ਸਕਦਾ ਹੈ। FastAPI ਇਸਨੂੰ ਬਿਲਟ-ਇਨ CORSMiddleware ਦੇ ਨਾਲ ਸੰਰਚਿਤ ਕਰਦਾ ਹੈ। ਜਦੋਂ ਵੀ ਵਿਭਿੰਨ ਡੋਮੇਨ/ਪੋਰਟ ਤੇ ਇੱਕ ਫ੍ਰੰਟਐਂਡ ਆਪਣੀ API ਨੂੰ ਕਾਲ ਕਰਦਾ ਹੈ ਤਾਂ ਤੁਹਾਨੂੰ CORS ਦਾ ਸਾਹਮਣਾ ਕਰਨਾ ਪਵੇਗਾ।
CORS ਜੋ ਸਮੱਸਿਆ ਨੂੰ ਹੱਲ ਕਰਦਾ ਹੈ
A React app at http://localhost:3000 calling an API at http://localhost:8000 is
CROSS-ORIGIN (different port). The BROWSER blocks the response unless the API
sends CORS headers permitting that origin.
(origin = scheme + host + port)
