add fronted docker
This commit is contained in:
1 parent
5cd5ec5649
commit
a18f7a5c8b
14 files changed
+124
-24
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
/**
|
||||
* /api/* 를 백엔드로 넘긴다. CORS를 쓰지 않는 이유가 이것이다.
|
||||
*
|
||||
* next.config.ts 의 rewrites 로는 안 된다 — Next가 빌드할 때 목적지를 평가해
|
||||
* routes-manifest.json 에 박아버려서, 이미지를 구운 뒤에는 환경변수를 바꿔도 안 먹는다.
|
||||
* proxy 는 Node 런타임에서 요청마다 돌아 그때 환경변수를 읽는다.
|
||||
*
|
||||
* 컨테이너에서는 서비스명(http://backend:30101), 로컬에서는 localhost.
|
||||
*/
|
||||
const API_ORIGIN = process.env.API_ORIGIN ?? "http://localhost:30101";
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const { pathname, search } = request.nextUrl;
|
||||
return NextResponse.rewrite(new URL(pathname + search, API_ORIGIN));
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/api/:path*",
|
||||
};
|
||||
Reference in new issue
Block a user