| 1 | |
| 2 | import { NextResponse } from 'next/server'; |
| 3 | |
| 4 | /** |
| 5 | * OSIRIS — Ukraine Frontline API |
| 6 | * Fetches live warfront GeoJSON from DeepState Map |
| 7 | */ |
| 8 | |
| 9 | export async function GET() { |
| 10 | try { |
| 11 | const url = 'https://deepstatemap.live/api/history/last'; |
| 12 | const res = await fetch(url, { |
| 13 | signal: AbortSignal.timeout(10000), // Cache 30 min |
| 14 | }); |
| 15 | |
| 16 | if (!res.ok) { |
| 17 | return NextResponse.json({ frontlines: null, error: 'DeepState unavailable' }); |
| 18 | } |
| 19 | |
| 20 | const data = await res.json(); |
| 21 | |
| 22 | return NextResponse.json({ |
| 23 | frontlines: data, |
| 24 | timestamp: new Date().toISOString(), |
| 25 | }, { |
| 26 | headers: { |
| 27 | 'Cache-Control': 'public, s-maxage=1800, stale-while-revalidate=3600', |
| 28 | }, |
| 29 | }); |
| 30 | } catch (error) { |
| 31 | console.error('Frontlines fetch error:', error); |
| 32 | return NextResponse.json({ frontlines: null, error: 'Failed to fetch frontline data' }, { status: 500 }); |
| 33 | } |
| 34 | } |
| 35 | |