import { NextRequest, NextResponse } from 'next/server'; import { getLinkById } from '../service'; export async function GET( request: NextRequest, context: { params: Promise } ) { try { // 获取参数,支持异步格式 const params = await context.params; const linkId = params.linkId; const link = await getLinkById(linkId); if (!link) { return NextResponse.json( { error: 'Link not found' }, { status: 404 } ); } return NextResponse.json(link); } catch (error) { console.error('Failed to fetch link:', error); return NextResponse.json( { error: 'Failed to fetch link', message: (error as Error).message }, { status: 500 } ); } }