From ce6a53875a5358691de9a2630230a6a8b150212d Mon Sep 17 00:00:00 2001 From: Kavalar Date: Fri, 7 Apr 2023 16:57:00 +0300 Subject: [PATCH] cors --- server.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server.py b/server.py index 8ce3bde..bc35ae9 100644 --- a/server.py +++ b/server.py @@ -5,6 +5,7 @@ from bearer.routes.auth import auth from db.DB import DBException import mimetypes from mime.mime import mime_content_type +from fastapi.middleware.cors import CORSMiddleware from fastapi import FastAPI, File, UploadFile, Form, Response, status, HTTPException @@ -15,6 +16,14 @@ app = FastAPI() app.include_router(user_route) app.include_router(auth) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + @app.get("/") def read_root(): return {"Hello": "World"}