Fixed upload flow

This commit is contained in:
headpatsyou 2026-01-08 19:15:20 +00:00
parent 0677b13902
commit a200dc05e3

View file

@ -1,12 +1,18 @@
import { NextRequest, NextResponse } from 'next/server'
import { writeFile } from 'node:fs/promises'
import { writeFile, readFile } from 'node:fs/promises'
import path from 'node:path'
import config from '@/config/config.json'
export const runtime = 'nodejs'
async function getConfig() {
const configPath = path.join(process.cwd(), 'src', 'config', 'config.json')
const content = await readFile(configPath, 'utf8')
return JSON.parse(content)
}
export async function POST(req: NextRequest) {
const password = req.headers.get('x-admin-password') || ''
const config = await getConfig()
if (password !== config.adminPassword) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })