fix: merge [channelId] into [id] in app/api/channels — Next.js slug conflict

This commit is contained in:
Ник (Claude)
2026-06-12 23:49:29 +03:00
parent 5bf01ec394
commit d888816f2b
@@ -0,0 +1,21 @@
import { NextResponse } from 'next/server';
import { requireUser } from '@/lib/session';
const ENGINE_URL = process.env.ENGINE_URL || 'http://127.0.0.1:3030';
const ENGINE_SECRET = process.env.ENGINE_SECRET || '';
export async function POST(req, { params }) {
const user = await requireUser();
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
const { searchParams } = new URL(req.url);
const body = await req.json().catch(() => ({}));
const res = await fetch(
`${ENGINE_URL}/api/channels/${params.id}/drafts/generate?count=${searchParams.get('count') || body.count || 3}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-internal-secret': ENGINE_SECRET, 'x-user-id': String(user.id) },
body: JSON.stringify(body),
}
);
return NextResponse.json(await res.json());
}