import { NextResponse } from 'next/server'; type TunnelAction = 'status' | 'start' | 'stop'; function getModuleBaseUrl(): string { return (process.env.INTRANET_PENETRATION_MODULE_URL || '').trim().replace(/\/+$/, ''); } export async function proxyIntranetModule(action: TunnelAction): Promise { const baseUrl = getModuleBaseUrl(); if (!baseUrl) return null; const method = action === 'status' ? 'GET' : 'POST'; const response = await fetch(`${baseUrl}/${action}`, { method }); const data = await response.json().catch(() => ({ error: '内网穿透模块返回数据异常', })); return NextResponse.json(data, { status: response.status }); }