refactor: 统一API鉴权并提升代码健壮性
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { isValidApiKey } from '@/lib/auth'
|
||||
import { z } from 'zod'
|
||||
|
||||
/**
|
||||
@@ -179,8 +180,7 @@ export async function POST(request: NextRequest) {
|
||||
const payload = validationResult.data
|
||||
|
||||
// Verify API Key
|
||||
const apiKey = process.env.WEBHOOK_API_KEY
|
||||
if (payload.apiKey !== apiKey) {
|
||||
if (!isValidApiKey(payload.apiKey)) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
|
||||
Reference in New Issue
Block a user