18 lines
863 B
TypeScript
18 lines
863 B
TypeScript
// apps/web/src/proxy.ts
|
|
// 외부 진입점(데스크톱·모바일·사이트가 여는 /app/billing?tier=…)으로 들어온 요청의 경로를
|
|
// (app) 레이아웃에 넘겨, 로그인이 필요할 때 로그인 뒤 같은 곳으로 돌아오게 한다.
|
|
|
|
import { NextResponse, type NextRequest } from 'next/server'
|
|
import { RETURN_PATH_HEADER } from '@/lib/web-app-url'
|
|
|
|
export function proxy(request: NextRequest): NextResponse {
|
|
const headers = new Headers(request.headers)
|
|
// nextUrl.pathname 은 basePath('/app')를 뺀 앱 경로다.
|
|
headers.set(RETURN_PATH_HEADER, `${request.nextUrl.pathname}${request.nextUrl.search}`)
|
|
return NextResponse.next({ request: { headers } })
|
|
}
|
|
|
|
export const config = {
|
|
// basePath 기준 경로. 외부에서 직접 여는 결제·초대 진입점만 대상이다.
|
|
matcher: ['/billing', '/accept-invite']
|
|
}
|