Complete the code to import the CORS middleware class from FastAPI.
from fastapi.middleware.[1] import CORSMiddleware
The correct import is CORSMiddleware from fastapi.middleware.cors (case-sensitive).
Complete the code to add the CORS middleware to the FastAPI app allowing all origins.
app.add_middleware(CORSMiddleware, allow_origins=[1], allow_credentials=True, allow_methods=["*"], allow_headers=["*"])
To allow all origins, use ['*'] for allow_origins.
Fix the error in the CORS middleware setup by completing the missing argument for allowed methods.
app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=[1], allow_headers=["*"])
The allow_methods argument expects a list of methods or ["*"] to allow all methods.
Fill both blanks to create a FastAPI app and add CORS middleware allowing only specific origins and methods.
app = [1]() app.add_middleware(CORSMiddleware, allow_origins=[2], allow_credentials=True, allow_methods=["GET", "POST"], allow_headers=["*"])
Create the app with FastAPI() and specify allowed origins as a list of URLs.
Fill all three blanks to configure CORS middleware with specific origins, methods, and headers.
app.add_middleware(CORSMiddleware, allow_origins=[1], allow_methods=[2], allow_headers=[3], allow_credentials=True)
Specify allowed origins as a list of URLs, allowed methods as a list of HTTP verbs, and allowed headers as a list of header names.