From bd94061fba367a6c8f117679b8cfeae01e6ba715 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 26 Aug 2026 09:25:58 +0900 Subject: [PATCH] =?UTF-8?q?260826=5F01=5FENH:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=8C=A8=EC=8A=A4=EB=A5=BC=20api=EB=B0=A9=EC=8B=9D=EC=9D=B4=20?= =?UTF-8?q?=EC=95=84=EB=8B=8C=20rewrite=EB=A1=9C=20=EC=9A=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 7 +++++++ next.config.ts | 17 +++++++++++++++-- src/lib/file-download.ts | 5 ++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 158fa34..7089400 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -251,6 +251,13 @@ When implementation is complete, report in Korean: - Validate external data at runtime; a shared TypeScript type alone does not validate an API response or persisted value. - Prefer named public exports and retain the consumer project's current module system and bundler conventions. +### React Compiler and Manual Memoization + +- `createKriNextConfig` enables `reactCompiler: true` unless the project overrides it; confirm the effective configuration. +- When enabled, rely on React Compiler instead of adding `useMemo`, `useCallback`, or `React.memo` as a routine performance precaution. +- Use manual memoization only for required reference stability, an Effect or third-party contract, compiler-incompatible code, or a measured performance problem. +- Preserve existing memoization unless approved and verified for removal. Use `"use memo"` or `"use no memo"` only for a documented compiler boundary. + ### Change Safety - Pin or constrain the package version according to the consumer repository's dependency policy and commit its lockfile changes. diff --git a/next.config.ts b/next.config.ts index 7d7957e..564c5e1 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,19 @@ import type { NextConfig } from "next"; -import { createKriNextConfig } from "@kri/common/config"; +import {createEnv, createKriNextConfig, env} from "@kri/common/config"; -const nextConfig = createKriNextConfig({}) satisfies NextConfig; +const nextEnv = createEnv({ + CONTACT_SERVER: env.required("CONTACT_SERVER", process.env.CONTACT_SERVER), +}); + +const nextConfig = createKriNextConfig({ + async rewrites() { + return [ + { + source: "/files/:path*", + destination: `${nextEnv.CONTACT_SERVER}/files/:path*`, + }, + ]; + }, +}) satisfies NextConfig; export default nextConfig; diff --git a/src/lib/file-download.ts b/src/lib/file-download.ts index 213ee6f..406b94f 100644 --- a/src/lib/file-download.ts +++ b/src/lib/file-download.ts @@ -1,7 +1,6 @@ -// 백엔드(파일 서버)가 테스트/운영 환경에서 내부망 전용 주소라 브라우저가 직접 접근할 수 없다. -// 프론트 자기 origin의 BFF 프록시(src/app/api/files/[...slug]/route.ts)를 거쳐 내려받는다. +// 백엔드의 상대 파일 경로는 next.config.ts의 rewrite를 통해 프론트 origin에서 내려받는다. export function toFileDownloadUrl(downloadUrl: string): string { - return `/api${downloadUrl}`; + return downloadUrl; } // 백엔드가 Content-Disposition: attachment를 내려주지 않아 PDF 등은 새 탭에 그냥 열려버린다.