FastAPI: CORS Middleware not working with GET method
18:59 07 Dec 2020

I try to use CORS on the FastAPi framework but it dose not working with GET method

Here's the code I'm working on:


from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=['*'],
    allow_methods=["*"],
    allow_headers=["*"],
)


@app.get("/test1")
async def test1():
    return {"message": "Hello World"}

fastapi