mirror of
https://github.com/MatrixSeven/file-transfer-go.git
synced 2026-05-21 05:07:29 +08:00
UI-React refactor
This commit is contained in:
28
chuan-next/src/app/api/create-room/route.ts
Normal file
28
chuan-next/src/app/api/create-room/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const GO_BACKEND_URL = process.env.GO_BACKEND_URL || 'http://localhost:8080';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
|
||||
// 转发请求到Go后端
|
||||
const response = await fetch(`${GO_BACKEND_URL}/api/create-room`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return NextResponse.json(data, { status: response.status });
|
||||
} catch (error) {
|
||||
console.error('Error creating room:', error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: '创建房间失败' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user