Add better error handling to aero

This commit is contained in:
Ryan Wilson
2024-09-24 12:06:16 -04:00
parent 97d305ddcc
commit 3c3dc996e4
3 changed files with 70 additions and 8 deletions
+19
View File
@@ -0,0 +1,19 @@
import fs from 'fs'
import { notFound } from 'next/navigation'
import { NextRequest } from 'next/server'
export async function GET(_req: NextRequest, { params }: { params: { aero: string } }) {
const requestedFile = params.aero
try {
const res = await fetch(`https://unpkg.com/browse/aero-proxy/extras/${requestedFile}`)
const file = await res.text()
const fileBlob = new Blob([file])
return new Response(fileBlob, {
headers: {
'Content-Type': 'application/javascript'
}
})
} catch {
notFound()
}
}