Fix store-status route always returning 401
The route had a redundant isAuthed() checking for 'bpb_admin' cookie, but login sets 'admin_token'. The middleware already guards all /api/admin/* routes, so the in-route check was just wrong. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9cac3a8e8a
commit
e7af5bca4a
@ -1,18 +1,11 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getStoreStatus, setStoreStatus } from '@/lib/store-status'
|
||||
import { cookies } from 'next/headers'
|
||||
|
||||
function isAuthed() {
|
||||
return cookies().get('bpb_admin')?.value === 'true'
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
if (!isAuthed()) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
return NextResponse.json(await getStoreStatus())
|
||||
}
|
||||
|
||||
export async function PUT(req: NextRequest) {
|
||||
if (!isAuthed()) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
const body = await req.json()
|
||||
const status = {
|
||||
closed: Boolean(body.closed),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user