summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-02-24 03:09:18 +0200
committerRasmus Luha <rasmus.luha@gmail.com>2022-02-24 03:09:18 +0200
commit21a733e3e84d988f23556b2dc79a81cb3dc2e7cc (patch)
treee77a3e26134c2e60d722fa940028592f8f3c3b16
parent7faf7cbeec2fc61db5043ab4853a62acdd0d3dbd (diff)
Added CORS access to *
-rw-r--r--app/main.py11
1 files changed, 11 insertions, 0 deletions
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)