fix: wrap Buffer in Uint8Array for Next.js Response API

Wrap Buffer objects with new Uint8Array() to satisfy Next.js
Response BodyInit type requirements.

Next.js 13+ requires BodyInit types (not Buffer) for Response
constructors. This change maintains binary compatibility while
satisfying the type checker.

Fixes 3 TS2345 errors in API routes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-07 15:16:06 -05:00
parent e73191a729
commit 98384d264e
3 changed files with 3 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ export async function GET(_request: NextRequest, { params }: { params: { id: str
console.log('✅ Asset found, serving download')
// Return file with appropriate headers
return new NextResponse(asset.data, {
return new NextResponse(new Uint8Array(asset.data), {
status: 200,
headers: {
'Content-Type': asset.mimeType,

View File

@@ -17,7 +17,7 @@ export async function GET(_request: NextRequest, { params }: { params: { id: str
headers.set('Content-Length', asset.data.length.toString())
headers.set('Cache-Control', 'no-cache, no-store, must-revalidate')
return new NextResponse(asset.data, {
return new NextResponse(new Uint8Array(asset.data), {
status: 200,
headers,
})

View File

@@ -62,7 +62,7 @@ export async function POST(request: NextRequest) {
const filename = `soroban-flashcards-${config.range || 'cards'}.pdf`
// Return PDF directly as download
return new NextResponse(pdfBuffer, {
return new NextResponse(new Uint8Array(pdfBuffer), {
headers: {
'Content-Type': 'application/pdf',
'Content-Disposition': `attachment; filename="${filename}"`,