diff options
author | Ernst Widerberg <ernst@sunet.se> | 2021-11-24 15:07:32 +0100 |
---|---|---|
committer | Ernst Widerberg <ernst@sunet.se> | 2021-11-24 15:07:32 +0100 |
commit | 2d594c65761c3e069a1ee50b7fac8ffec8e15081 (patch) | |
tree | d456e130f3bd99d2c2b7dc345095532a18099faa | |
parent | 1d9b2b2fd9a676467f16b951f221e8a04b4edf63 (diff) |
Add CORS middleware
-rwxr-xr-x | src/main.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.py b/src/main.py index 29d7088..4d20c84 100755 --- a/src/main.py +++ b/src/main.py @@ -6,6 +6,7 @@ from fastapi import FastAPI, Depends, Request from fastapi.responses import JSONResponse from fastapi_jwt_auth import AuthJWT from fastapi_jwt_auth.exceptions import AuthJWTException +from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel from index import CouchIindex import time @@ -13,6 +14,14 @@ from db import DictDB app = FastAPI() +app.add_middleware( + CORSMiddleware, + allow_origins=["http://localhost:8001"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + for i in range(10): try: db = DictDB() |