docs: fix api-reference with proxy (#7952)

This commit is contained in:
Shahed Nasser
2024-07-04 17:10:48 +02:00
committed by GitHub
parent 0d534d4f70
commit 1acbcf612e
17 changed files with 24 additions and 20 deletions
@@ -1,29 +0,0 @@
import { existsSync, readFileSync } from "fs"
import { NextResponse } from "next/server"
import path from "path"
type DownloadParams = {
params: {
area: string
}
}
export function GET(request: Request, { params }: DownloadParams) {
const { area } = params
const filePath = path.join(process.cwd(), "specs", area, "openapi.full.yaml")
if (!existsSync(filePath)) {
return new NextResponse(null, {
status: 404,
})
}
const fileContent = readFileSync(filePath)
return new Response(fileContent, {
headers: {
"Content-Type": "application/x-yaml",
"Content-Disposition": `attachment; filename="openapi.yaml"`,
},
})
}