From 9e510b01839e18b997cd3865aeed621e65c997e7 Mon Sep 17 00:00:00 2001 From: "maxiaozhe@alicorns.co.jp" Date: Wed, 26 Jul 2023 23:51:44 +0900 Subject: [PATCH] =?UTF-8?q?CORS=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/db/models.py | 4 ++-- backend/app/main.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/app/db/models.py b/backend/app/db/models.py index b841b7a..0e6812b 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -27,5 +27,5 @@ class Kintone(Base): id = Column(Integer, primary_key=True, index=True) type = Column(Integer, index=True, nullable=False) name = Column(String(100), nullable=False) - desc = Column(String(500)) - content = Column(String(2000)) \ No newline at end of file + desc = Column(String) + content = Column(String) \ No newline at end of file diff --git a/backend/app/main.py b/backend/app/main.py index b792b7f..0175c69 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -10,7 +10,7 @@ from app.db import Base,engine from app.core.auth import get_current_active_user from app.core.celery_app import celery_app from app import tasks - +from fastapi.middleware.cors import CORSMiddleware Base.metadata.create_all(bind=engine) @@ -18,6 +18,19 @@ app = FastAPI( title=config.PROJECT_NAME, docs_url="/api/docs", openapi_url="/api" ) +origins = [ + "http://localhost:9000", + "http://localhost", + "http://localhost:8080", +] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) # @app.middleware("http") # async def db_session_middleware(request: Request, call_next):