-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
24 lines (22 loc) · 851 Bytes
/
Copy pathroute.ts
File metadata and controls
24 lines (22 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NextRequest, NextResponse } from 'next/server';
import { backendRoutes } from '@/lib/api-routes';
import { proxyWrite } from '@/lib/proxy';
import { backendUrl } from '@/lib/server-api';
/** GET /api/tasks — list proxy (reads are unguarded); used by client-side "load more". */
export async function GET(req: NextRequest) {
const res = await fetch(
backendUrl(`${backendRoutes.tasks}${req.nextUrl.search}`),
{ cache: 'no-store' },
);
const data = await res.text();
return new NextResponse(data, {
status: res.status,
headers: {
'Content-Type': res.headers.get('content-type') ?? 'application/json',
},
});
}
/** POST /api/tasks — create-task proxy (API key injected server-side). */
export async function POST(req: NextRequest) {
return proxyWrite('POST', backendRoutes.tasks, await req.text());
}