Skip to content

Commit

Permalink
fix: added cron secret
Browse files Browse the repository at this point in the history
  • Loading branch information
hemantwasthere committed Oct 28, 2024
1 parent 050619b commit 78662f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ DATABASE_URL=
ACCOUNT_PK=0x0574ba4998dd9aedf1c4d6e56b747b29256a795bc3846437d121cd64b972bdd8
NEXT_PUBLIC_OG_NFT_CONTRACT=0x3cb654f2f557a7f71a0c16d97c05a2dec62a0b744979d11afc95b804e1d7307


CRON_SECRET=
9 changes: 8 additions & 1 deletion src/app/api/raffle/luckyWinner/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { NextResponse } from 'next/server';

export const dynamic = 'force-dynamic'; // static by default, unless reading the request

export async function GET() {
export async function GET(request: Request) {
const authHeader = request.headers.get('authorization');
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return new Response('Unauthorized', {
status: 401,
});
}

try {
// Fetch all raffle participants
const raffleParticipants = await db.raffle.findMany({
Expand Down

0 comments on commit 78662f0

Please sign in to comment.