fix(returns): CORM 으로 보내는 반품 신청 URL 및 인증 헤더 갱신
- CS_RETURN_REQUEST_URL 기본값을 http://dbx-corm:8002/api/return/request 로 (docker 컨테이너 간 통신, 옛 127.0.0.1:8001 폐기). - httpx 요청에 X-Service-Token 헤더 첨부 (CORM AuthGuard 우회용). INTERNAL_SERVICE_TOKEN env 가 있을 때만 첨부. - .env.example 에 두 항목 안내 추가.
This commit is contained in:
@@ -44,6 +44,14 @@ TRUSTED_NAME_HEADER=X-Forwarded-User-Name
|
|||||||
|
|
||||||
# dbx-main 에서 인증된 사용자를 OMS DB 에 자동 등록할지
|
# dbx-main 에서 인증된 사용자를 OMS DB 에 자동 등록할지
|
||||||
AUTO_PROVISION_USERS=1
|
AUTO_PROVISION_USERS=1
|
||||||
|
|
||||||
|
# ===== 서비스 간 호출 (OMS → CORM 반품 신청) =====
|
||||||
|
# CORM 컨테이너 이름 기반 URL. NPM 거치지 않고 docker network 로 직접 호출.
|
||||||
|
CS_RETURN_REQUEST_URL=http://dbx-corm:8002/api/return/request
|
||||||
|
|
||||||
|
# 서비스 간 인증 토큰. OMS 와 CORM 양쪽 .env 에 동일한 값으로 박을 것.
|
||||||
|
# openssl rand -hex 32 로 생성.
|
||||||
|
INTERNAL_SERVICE_TOKEN=__paste-same-value-as-dbx-corm__
|
||||||
# 자동 등록 시 is_admin=True 로 만들 이메일(쉼표 구분)
|
# 자동 등록 시 is_admin=True 로 만들 이메일(쉼표 구분)
|
||||||
ADMIN_EMAILS=king@dbxcorp.co.kr
|
ADMIN_EMAILS=king@dbxcorp.co.kr
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ from app.search_utils import (
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
CS_RETURN_REQUEST_URL = os.getenv(
|
CS_RETURN_REQUEST_URL = os.getenv(
|
||||||
"CS_RETURN_REQUEST_URL",
|
"CS_RETURN_REQUEST_URL",
|
||||||
"http://127.0.0.1:8001/api/return/request",
|
"http://dbx-corm:8002/api/return/request",
|
||||||
)
|
)
|
||||||
|
# 서비스 간 호출 인증용 토큰 (양쪽 .env 에 같은 값으로 박는다).
|
||||||
|
# CORM 의 AuthGuard 가 이 헤더를 보고 세션 검사 우회.
|
||||||
|
INTERNAL_SERVICE_TOKEN = os.getenv("INTERNAL_SERVICE_TOKEN", "")
|
||||||
|
|
||||||
# Global dict to hold upload progress. In a real world scenario this should be in Redis or DB.
|
# Global dict to hold upload progress. In a real world scenario this should be in Redis or DB.
|
||||||
upload_progress_state = {}
|
upload_progress_state = {}
|
||||||
@@ -942,8 +945,11 @@ async def send_return_request(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
timeout = httpx.Timeout(connect=2.0, read=5.0, write=3.0, pool=2.0)
|
timeout = httpx.Timeout(connect=2.0, read=5.0, write=3.0, pool=2.0)
|
||||||
|
headers = {}
|
||||||
|
if INTERNAL_SERVICE_TOKEN:
|
||||||
|
headers["X-Service-Token"] = INTERNAL_SERVICE_TOKEN
|
||||||
async with httpx.AsyncClient(timeout=timeout, trust_env=False) as client:
|
async with httpx.AsyncClient(timeout=timeout, trust_env=False) as client:
|
||||||
response = await client.post(CS_RETURN_REQUEST_URL, json=payload)
|
response = await client.post(CS_RETURN_REQUEST_URL, json=payload, headers=headers)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except httpx.HTTPStatusError as exc:
|
except httpx.HTTPStatusError as exc:
|
||||||
response_text = exc.response.text[:1000] if exc.response is not None else ""
|
response_text = exc.response.text[:1000] if exc.response is not None else ""
|
||||||
|
|||||||
Reference in New Issue
Block a user