sub-path 배포 지원 (root_path) + HTML 상대경로화
Apache 리버스 프록시로 /plagiarism 같은 sub-path에 배포 가능하도록: - config.Settings.root_path 추가 (.env의 ROOT_PATH) - FastAPI app(root_path=...) + uvicorn run(root_path=..., proxy_headers=True, forwarded_allow_ips="*") - index.html의 모든 절대경로(/v1/..., /docs, /openapi.json)를 상대경로로 변경 - .env / .env.example 에 ROOT_PATH 추가 URL 직접 노출(localhost:8000)이든 sub-path(/plagiarism)든 모두 동작.
This commit is contained in:
1 parent
66dea0cc52
commit
b8370f5c1a
4 files changed
+17
-8
No files matched your search
@@ -40,6 +40,8 @@ def rebuild_detector(app: FastAPI) -> int:
|
||||
return app.state.detector.corpus_size
|
||||
|
||||
|
||||
_settings = get_settings()
|
||||
|
||||
app = FastAPI(
|
||||
title="O2O 저작권 침해 여부 탐지 API",
|
||||
description=(
|
||||
@@ -48,6 +50,7 @@ app = FastAPI(
|
||||
),
|
||||
version="1.0.0",
|
||||
lifespan=lifespan,
|
||||
root_path=_settings.root_path,
|
||||
)
|
||||
|
||||
app.include_router(api_router)
|
||||
@@ -83,6 +86,9 @@ def main() -> None:
|
||||
port=settings.port,
|
||||
log_level=settings.log_level,
|
||||
reload=settings.reload,
|
||||
root_path=settings.root_path,
|
||||
forwarded_allow_ips="*", # 리버스 프록시(Apache) 헤더 신뢰
|
||||
proxy_headers=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user