Route AeroSandbox as well

This commit is contained in:
Ryan Wilson 2024-09-24 11:45:30 -04:00
parent bb725fcf54
commit 42af80da9c
2 changed files with 20 additions and 2 deletions

View file

@ -2,8 +2,8 @@ import fs from 'fs'
import { notFound } from 'next/navigation'
import { NextRequest } from 'next/server'
export async function GET(_req: NextRequest, { params }: { params: { uv: string } }) {
const requestedFile = params.uv
export async function GET(_req: NextRequest, { params }: { params: { aero: string } }) {
const requestedFile = params.aero
if (requestedFile === 'aero.config.js') {
const file = fs.readFileSync(process.cwd() + `/src/lib/aero/${requestedFile}`)
const fileBlob = new Blob([file])

View file

@ -0,0 +1,18 @@
import { notFound } from 'next/navigation'
import { NextRequest } from 'next/server'
export async function GET(_req: NextRequest, { params }: { params: { aeroSandbox: string } }) {
const requestedFile = params.aeroSandbox
try {
const res = await fetch(`https://unpkg.com/browse/aero-sandbox@0.0.3/dist/${requestedFile}`)
const file = await res.text()
const fileBlob = new Blob([file])
return new Response(fileBlob, {
headers: {
'Content-Type': 'application/javascript'
}
})
} catch {
notFound()
}
}