Fix proxy — auth routes bypass /api/ prefix
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user