CORS Middleware

noun

say it: “KORZ MID-ul-wair” /kɔrz ˈmɪdəlwɛr/

FastAPI's CORSMiddleware, which adds the headers that tell browsers which other sites' pages may call your API.

What is CORS Middleware?

CORSMiddleware lets web pages on other domains call your API from the browser.

app.add_middleware(CORSMiddleware, allow_origins=['https://www.example.com'], allow_methods=['*'])

In a sentence

  • “The CORS middleware allows one origin, never *.”
  • “CORS middleware lets the coffee club's web page, at another address, call the API.”

Level: Journeyman · More FastAPI terms at this level

Updated