CORS (Cross-Origin Resource Sharing) on selaimen suojaustoiminto, joka hallitsee, voiko yhden alkuperän verkkosivusto kutsua API:si eri alkuperässä. FastAPI konfiguroi sen sisäänrakennetulla CORSMiddleware -ohjelmistolla. Kohtaat CORS:n aina, kun eri toimialueella/portissa oleva frontend kutsuu API:si.
Ongelma, jonka CORS ratkaisee
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)
