fix: restructure inbox API routes — channel/ and message/ namespaces
Next.js не позволяет [channelId] и [id] на одном уровне. Решение: /api/inbox/channel/[channelId]/* и /api/inbox/message/[id]/* InboxTab: все fetch пути обновлены
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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 GET(req, { params }) {
|
||||
const user = await requireUser();
|
||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
const { searchParams } = new URL(req.url);
|
||||
const res = await fetch(
|
||||
`${ENGINE_URL}/api/inbox/${params.channelId}?${searchParams.toString()}`,
|
||||
{ headers: { 'x-internal-secret': ENGINE_SECRET, 'x-user-id': String(user.id) } }
|
||||
);
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
Reference in New Issue
Block a user