feat(F-131): completed feature

This commit is contained in:
chattie
2026-08-21 17:50:31 +02:00
parent f37333bb56
commit e5126797a6
10 changed files with 229 additions and 15 deletions

View File

@@ -12,9 +12,10 @@ const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://127.0.0.1:3000';
*/
export async function GET(req: NextRequest) {
const path = req.nextUrl.pathname.replace('/api/', '');
const search = req.nextUrl.search;
const cookies = req.headers.get('cookie') ?? '';
try {
const backendRes = await fetch(`${API}/${path}`, {
const backendRes = await fetch(`${API}/${path}${search}`, {
headers: { Cookie: cookies },
});
if (path === 'admin/logs/stream') {
@@ -37,12 +38,13 @@ export async function GET(req: NextRequest) {
export async function POST(req: NextRequest) {
const path = req.nextUrl.pathname.replace('/api/', '');
const search = req.nextUrl.search;
const cookies = req.headers.get('cookie') ?? '';
const body = await req.text();
try {
const headers: Record<string, string> = { Cookie: cookies };
if (body) headers['Content-Type'] = 'application/json';
const backendRes = await fetch(`${API}/${path}`, {
const backendRes = await fetch(`${API}/${path}${search}`, {
method: 'POST',
headers,
...(body ? { body } : {}),
@@ -64,10 +66,11 @@ export async function POST(req: NextRequest) {
export async function PATCH(req: NextRequest) {
const path = req.nextUrl.pathname.replace('/api/', '');
const search = req.nextUrl.search;
const cookies = req.headers.get('cookie') ?? '';
const body = await req.text();
try {
const backendRes = await fetch(`${API}/${path}`, {
const backendRes = await fetch(`${API}/${path}${search}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', Cookie: cookies },
body,
@@ -81,10 +84,11 @@ export async function PATCH(req: NextRequest) {
export async function PUT(req: NextRequest) {
const path = req.nextUrl.pathname.replace('/api/', '');
const search = req.nextUrl.search;
const cookies = req.headers.get('cookie') ?? '';
const body = await req.text();
try {
const backendRes = await fetch(`${API}/${path}`, {
const backendRes = await fetch(`${API}/${path}${search}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json', Cookie: cookies },
body,
@@ -98,9 +102,10 @@ export async function PUT(req: NextRequest) {
export async function DELETE(req: NextRequest) {
const path = req.nextUrl.pathname.replace('/api/', '');
const search = req.nextUrl.search;
const cookies = req.headers.get('cookie') ?? '';
try {
const backendRes = await fetch(`${API}/${path}`, {
const backendRes = await fetch(`${API}/${path}${search}`, {
method: 'DELETE',
headers: { Cookie: cookies },
});