Route AeroSandbox as well
This commit is contained in:
parent
bb725fcf54
commit
42af80da9c
2 changed files with 20 additions and 2 deletions
|
|
@ -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])
|
||||
|
|
|
|||
18
src/app/aero/sandbox/[sandbox]/route.ts
Normal file
18
src/app/aero/sandbox/[sandbox]/route.ts
Normal 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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue