260826_02_ENH: 기존 우회 라우트 제거
This commit is contained in:
@@ -258,6 +258,10 @@ When implementation is complete, report in Korean:
|
||||
- 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.
|
||||
|
||||
### Project Instruction Budget
|
||||
|
||||
- Keep `.agent/project.md` at or below 8 KiB (8,192 bytes) as the normal target. Do not delete material rules merely to meet the budget; move schemas, endpoint inventories, examples, and temporary issue history to linked project documentation, and keep concise read-routing instructions here.
|
||||
|
||||
### Change Safety
|
||||
|
||||
- Pin or constrain the package version according to the consumer repository's dependency policy and commit its lockfile changes.
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { NextConfig } from "next";
|
||||
import {createEnv, createKriNextConfig, env} from "@kri/common/config";
|
||||
|
||||
const nextEnv = createEnv({
|
||||
CONTACT_SERVER: env.required("CONTACT_SERVER", process.env.CONTACT_SERVER),
|
||||
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
|
||||
});
|
||||
|
||||
const nextConfig = createKriNextConfig({
|
||||
@@ -10,7 +10,7 @@ const nextConfig = createKriNextConfig({
|
||||
return [
|
||||
{
|
||||
source: "/files/:path*",
|
||||
destination: `${nextEnv.CONTACT_SERVER}/files/:path*`,
|
||||
destination: `${nextEnv.API_SERVER}/files/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
// 파일 서버(백엔드와 동일 호스트)가 테스트/운영 환경에서 내부망 전용이라 브라우저가 직접 접근할 수 없다.
|
||||
// 내부망에 접근 가능한 건 이 Next.js 서버뿐이므로, 여기서 대신 받아 그대로 스트리밍해서 전달한다.
|
||||
export async function GET(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!slug.length) return new NextResponse(null, { status: 404 });
|
||||
|
||||
const fileOrigin = new URL(serverEnv.API_SERVER).origin;
|
||||
const targetUrl = `${fileOrigin}/files/${slug.map(encodeURIComponent).join("/")}${request.nextUrl.search}`;
|
||||
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
|
||||
|
||||
const backendResponse = await fetch(targetUrl, {
|
||||
headers: accessToken ? { authorization: `Bearer ${accessToken}` } : undefined,
|
||||
});
|
||||
|
||||
if (!backendResponse.ok || !backendResponse.body) {
|
||||
return new NextResponse(null, { status: backendResponse.status });
|
||||
}
|
||||
|
||||
return new NextResponse(backendResponse.body, {
|
||||
status: backendResponse.status,
|
||||
headers: {
|
||||
"content-type": backendResponse.headers.get("content-type") ?? "application/octet-stream",
|
||||
...(backendResponse.headers.get("content-length")
|
||||
? { "content-length": backendResponse.headers.get("content-length")! }
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user