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:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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}"`,
|
||||
|
||||
Reference in New Issue
Block a user