From 21a733e3e84d988f23556b2dc79a81cb3dc2e7cc Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Thu, 24 Feb 2022 03:09:18 +0200 Subject: Added CORS access to * --- app/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/main.py b/app/main.py index cd576c6..91111eb 100644 --- a/app/main.py +++ b/app/main.py @@ -1,4 +1,6 @@ from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware + from . import models from .database import engine, SessionLocal from .routers import post, user, auth, vote @@ -7,6 +9,15 @@ from .config import settings #models.Base.metadata.create_all(bind=engine) -- was needed for sqlalchemy before alembic app = FastAPI() +origins = ["*"] +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + app.include_router(post.router) app.include_router(user.router) app.include_router(auth.router) -- cgit v1.2.3