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:
2026-05-24 18:14:49 +09:00
parent 53a2d222b0
commit 274507e2af
2 changed files with 16 additions and 2 deletions
+8 -2
View File
@@ -31,8 +31,11 @@ from app.search_utils import (
router = APIRouter()
CS_RETURN_REQUEST_URL = os.getenv(
"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.
upload_progress_state = {}
@@ -942,8 +945,11 @@ async def send_return_request(
try:
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:
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()
except httpx.HTTPStatusError as exc:
response_text = exc.response.text[:1000] if exc.response is not None else ""