定时任务增加鉴权

This commit is contained in:
mtvpls
2026-01-01 22:38:42 +08:00
parent 97d748fa79
commit 70cb6f6589
4 changed files with 17 additions and 4 deletions

View File

@@ -11,8 +11,20 @@ import { SearchResult } from '@/lib/types';
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
export async function GET(
request: NextRequest,
{ params }: { params: { password: string } }
) {
console.log(request.url);
const cronPassword = process.env.CRON_PASSWORD || 'mtvpls';
if (params.password !== cronPassword) {
return NextResponse.json(
{ success: false, message: 'Unauthorized' },
{ status: 401 }
);
}
try {
console.log('Cron job triggered:', new Date().toISOString());