Skip to content

Commit 87cd356

Browse files
fx route
1 parent 6cd44ce commit 87cd356

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

next.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4-
/* config options here */
4+
async rewrites() {
5+
return [
6+
{
7+
source: '/api/gateway/proxy/:path*',
8+
destination: '/api/gateway/proxy?path=:path*',
9+
},
10+
]
11+
},
512
};
613

714
export default nextConfig;

src/app/api/gateway/proxy/[[...path]]/route.ts renamed to src/app/api/gateway/proxy/route.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,8 @@ function parseUsageFromSSEChunk(text: string): { inputTokens: number; outputToke
8181
return null
8282
}
8383

84-
export async function POST(
85-
request: NextRequest,
86-
{ params }: { params: Promise<{ path?: string[] }> },
87-
) {
88-
const { path } = await params
89-
const subPath = path?.join('/') ?? 'chat/completions'
84+
export async function POST(request: NextRequest) {
85+
const subPath = request.nextUrl.searchParams.get('path') || 'chat/completions'
9086

9187
const authHeader = request.headers.get('authorization')
9288
const token = authHeader?.startsWith('Bearer ')

0 commit comments

Comments
 (0)