Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/RomRom-ADMIN-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- test
- main

jobs:
build:
Expand Down
12 changes: 6 additions & 6 deletions src/app/api/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const proxy = createProxy({
stripRequestHeaders: ['content-length'],
});

export function GET(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function GET(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}

export function POST(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function POST(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}

export function PUT(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function PUT(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}

export function PATCH(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function PATCH(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}

export function DELETE(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function DELETE(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}

export function OPTIONS(req: NextRequest, ctx: ProxyContext): Promise<Response> {
export async function OPTIONS(req: NextRequest, ctx: ProxyContext): Promise<Response> {
return proxy(req, ctx);
}
5 changes: 3 additions & 2 deletions src/lib/bff/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse, type NextRequest } from 'next/server';
import { type NextRequest, NextResponse } from 'next/server';
import type { ProxyConfig, ProxyContext, ProxyHandler } from './types';

/** URL 안전 결합 (중복 슬래시 제거) */
Expand Down Expand Up @@ -50,7 +50,8 @@ export function createProxy(config: ProxyConfig): ProxyHandler {
const backendHost = backendUrl.host;

return async (req: NextRequest, ctx: ProxyContext): Promise<Response> => {
const path = (ctx.params?.path ?? []).join('/');
const { path: segs } = await ctx.params;
const path = Array.isArray(segs) ? segs.join('/') : '';
const target = joinUrl(config.backendBaseUrl, path, new URL(req.url).search);

const upstreamHeaders = buildUpstreamHeaders(req, backendHost, config);
Expand Down
4 changes: 1 addition & 3 deletions src/lib/bff/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import { NextRequest } from "next/server";

export interface ProxyContext {
readonly params: {
readonly path: string[];
};
readonly params: Promise<{ path: string[] }>
}

// 프록시 실행에 필요한 설정
Expand Down
2 changes: 1 addition & 1 deletion src/lib/error/error-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const ERROR_CODES = {
INVALID_REQUEST: {status: 400, message: '유효하지 않은 요청입니다.'},

// AUTH
LOGIN_FAILED: {status: 400, message: '로그인에 실패했습니다'},
LOGIN_FAILED: {status: 401, message: '로그인에 실패했습니다'},
} as const;

export type ErrorCodeKey = keyof typeof ERROR_CODES;
Expand Down
Loading