59016a7490
Next.js не позволяет [channelId] и [id] на одном уровне. Решение: /api/inbox/channel/[channelId]/* и /api/inbox/message/[id]/* InboxTab: все fetch пути обновлены
18 lines
738 B
JavaScript
18 lines
738 B
JavaScript
import { NextResponse } from 'next/server';
|
|
import { requireUser } from '@/lib/session';
|
|
|
|
const ENGINE_URL = process.env.ENGINE_URL || 'http://localhost: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 body = await req.json().catch(() => ({}));
|
|
const res = await fetch(`${ENGINE_URL}/api/inbox/${params.id}/status`, {
|
|
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());
|
|
}
|