CORS追加

This commit is contained in:
2023-07-26 23:51:44 +09:00
parent e49f0b7301
commit 9e510b0183
2 changed files with 16 additions and 3 deletions

View File

@@ -27,5 +27,5 @@ class Kintone(Base):
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
type = Column(Integer, index=True, nullable=False) type = Column(Integer, index=True, nullable=False)
name = Column(String(100), nullable=False) name = Column(String(100), nullable=False)
desc = Column(String(500)) desc = Column(String)
content = Column(String(2000)) content = Column(String)

View File

@@ -10,7 +10,7 @@ from app.db import Base,engine
from app.core.auth import get_current_active_user from app.core.auth import get_current_active_user
from app.core.celery_app import celery_app from app.core.celery_app import celery_app
from app import tasks from app import tasks
from fastapi.middleware.cors import CORSMiddleware
Base.metadata.create_all(bind=engine) Base.metadata.create_all(bind=engine)
@@ -18,6 +18,19 @@ app = FastAPI(
title=config.PROJECT_NAME, docs_url="/api/docs", openapi_url="/api" 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") # @app.middleware("http")
# async def db_session_middleware(request: Request, call_next): # async def db_session_middleware(request: Request, call_next):