| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import { NextRequest, NextResponse } from 'next/server'
- export async function GET(request: NextRequest) {
- try {
- const searchParams = request.nextUrl.searchParams
- const page = searchParams.get('page') || '1'
- const pageSize = searchParams.get('pageSize') || '500'
- const address = searchParams.get('userAddress')
- const status = searchParams.get('status') || '0'
- const tokenAddress = searchParams.get('tokenAddress') || ''
- const response = await fetch(
- `https://api2.byreal.io/byreal/api/dex/v2/position/list?userAddress=${address}&page=${page}&pageSize=${pageSize}&tokenAddress=${tokenAddress}&status=${status}`,
- {
- method: 'GET',
- headers: {
- accept: 'application/json',
- },
- }
- )
- if (!response.ok) {
- return NextResponse.json(
- { retCode: response.status, retMsg: '外部 API 请求失败' },
- { status: response.status }
- )
- }
- const data = await response.json()
- return NextResponse.json(data)
- } catch (error) {
- console.error('API Route Error:', error)
- return NextResponse.json(
- { retCode: 500, retMsg: '服务器内部错误' },
- { status: 500 }
- )
- }
- }
|