- 토큰 저장 키 통일 (access_token으로 일관성 확보) - 일일공수 페이지 API 스크립트 로딩 순서 수정 - 프로젝트 관리 페이지 비활성 프로젝트 표시 문제 해결 - 업로드 카테고리에 '기타' 항목 추가 (백엔드 schemas.py 포함) - 비밀번호 변경 기능 API 연동으로 수정 - 프로젝트 드롭다운 z-index 문제 해결 - CORS 설정 및 Nginx 구성 개선 - 비밀번호 해싱 방식 pbkdf2_sha256으로 변경 (bcrypt 72바이트 제한 해결)
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
from fastapi import FastAPI, Request
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
import uvicorn
|
|
|
|
from database.database import engine, get_db
|
|
from database.models import Base
|
|
from routers import auth, issues, daily_work, reports, projects
|
|
from services.auth_service import create_admin_user
|
|
|
|
# 데이터베이스 테이블 생성
|
|
# 메타데이터 캐시 클리어
|
|
Base.metadata.clear()
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
# FastAPI 앱 생성
|
|
app = FastAPI(
|
|
title="M-Project API",
|
|
description="작업보고서 시스템 API",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS 설정 (완전 개방 - CORS 문제 해결)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=False, # * origin과 credentials는 함께 사용 불가
|
|
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
allow_headers=["*"],
|
|
expose_headers=["*"]
|
|
)
|
|
|
|
# 라우터 등록
|
|
app.include_router(auth.router)
|
|
app.include_router(issues.router)
|
|
app.include_router(daily_work.router)
|
|
app.include_router(reports.router)
|
|
app.include_router(projects.router)
|
|
|
|
# 시작 시 관리자 계정 생성
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
db = next(get_db())
|
|
create_admin_user(db)
|
|
db.close()
|
|
|
|
# 루트 엔드포인트
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "M-Project API", "version": "1.0.0"}
|
|
|
|
# 헬스체크
|
|
@app.get("/api/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
# 전역 예외 처리
|
|
@app.exception_handler(Exception)
|
|
async def global_exception_handler(request: Request, exc: Exception):
|
|
return JSONResponse(
|
|
status_code=500,
|
|
content={"detail": f"Internal server error: {str(exc)}"}
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|