Added profile button (#21)

This commit is contained in:
Doh
2025-01-04 14:10:28 -05:00
committed by GitHub
parent f04a5e484c
commit fadf33e8df
12 changed files with 725 additions and 131 deletions

View File

@@ -0,0 +1,26 @@
import { NextResponse } from 'next/server'
import fs from 'fs/promises'
import path from 'path'
export async function GET(
request: Request,
{ params }: { params: Promise<{ path: string[] }> }
) {
try {
const { path: pathSegments } = await Promise.resolve(params)
const filePath = path.join(process.cwd(), 'data', 'avatars', ...(pathSegments || []))
const file = await fs.readFile(filePath)
const ext = path.extname(filePath).slice(1)
return new NextResponse(file, {
headers: {
'Content-Type': `image/${ext}`,
},
})
} catch (error) {
return NextResponse.json(
{ error: 'File not found' },
{ status: 404 }
)
}
}