diff --git a/deploy/k8s/overlays/prod/kustomization.yaml b/deploy/k8s/overlays/prod/kustomization.yaml index d053a86..7726190 100644 --- a/deploy/k8s/overlays/prod/kustomization.yaml +++ b/deploy/k8s/overlays/prod/kustomization.yaml @@ -13,7 +13,7 @@ commonLabels: # 이미지 태그 설정 images: - name: ghcr.io/mayne0213/portfolio - newTag: main-sha-4f895110ef62cc58495fc98f825d39ed42088d25 + newTag: main-sha-e3bc9910461de2af95c3fcfa8190bd47a5e9e519 patchesStrategicMerge: - deployment-patch.yaml diff --git a/services/nextjs/app/api/argocd/route.ts b/services/nextjs/app/api/argocd/route.ts index 9344ef9..8c826d1 100644 --- a/services/nextjs/app/api/argocd/route.ts +++ b/services/nextjs/app/api/argocd/route.ts @@ -1,4 +1,6 @@ import { NextRequest, NextResponse } from 'next/server'; +import https from 'https'; +import { URL } from 'url'; // 클러스터 내부에서 실행되는 경우 클러스터 내부 서비스 URL 사용 // 외부에서 실행되는 경우 환경 변수로 설정 가능 @@ -13,23 +15,47 @@ async function fetchWithCert(url: string, options: RequestInit = {}): Promise { + const urlObj = new URL(url); + const requestOptions: https.RequestOptions = { + hostname: urlObj.hostname, + port: urlObj.port || 443, + path: urlObj.pathname + urlObj.search, + method: options.method || 'GET', + headers: { + ...(options.headers as Record), + }, + ca: ARGOCD_CA_CERT, + rejectUnauthorized: true, + }; + + const req = https.request(requestOptions, (res) => { + let data = ''; + res.on('data', (chunk) => { + data += chunk; + }); + res.on('end', () => { + const response = new Response(data, { + status: res.statusCode || 200, + statusText: res.statusMessage || 'OK', + headers: res.headers as HeadersInit, + }); + resolve(response); + }); + }); + + req.on('error', (error) => { + reject(error); + }); + + if (options.body) { + req.write(typeof options.body === 'string' ? options.body : JSON.stringify(options.body)); + } + + req.end(); }); - - // Node.js의 fetch에 agent 전달 - const nodeOptions: any = { - ...options, - agent, - }; - - return fetch(url, nodeOptions); } return fetch(url, options);