Fix proxy — auth routes bypass /api/ prefix

This commit is contained in:
2026-04-26 15:48:40 +00:00
parent 3b63e0076f
commit 3681eec9eb
+6 -6
View File
@@ -7,20 +7,20 @@ async function handler(
{ params }: { params: Promise<{ slug: string[] }> }
) {
const { slug } = await params;
const path = '/api/' + slug.join('/');
const slugPath = slug.join('/');
// Auth routes go directly without /api/ prefix
const isAuth = slugPath.startsWith('auth/');
const path = isAuth ? `/${slugPath}` : `/api/${slugPath}`;
const url = `${API_BASE}${path}${request.nextUrl.search}`;
const headers = new Headers();
// Forward content-type exactly (includes multipart boundary)
const contentType = request.headers.get('content-type');
if (contentType) headers.set('content-type', contentType);
// Forward session cookie
const cookie = request.headers.get('cookie');
if (cookie) headers.set('cookie', cookie);
// Forward body
let body: BodyInit | undefined;
if (request.method !== 'GET' && request.method !== 'HEAD') {
body = await request.arrayBuffer();