-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from movementlabsxyz/imola-baku
hot fix
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async function handler(req: NextRequest) { | ||
const { recaptchaResponse } = await req.json(); | ||
|
||
if (!recaptchaResponse) { | ||
return NextResponse.json({ success: false, message: 'No CAPTCHA token provided' }, { status: 400 }); | ||
} | ||
|
||
const secretKey = process.env.RECAPTCHA_SECRET_KEY; | ||
|
||
const verificationResponse = await fetch(`https://www.google.com/recaptcha/api/siteverify`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
body: `secret=${secretKey}&response=${recaptchaResponse}`, | ||
}); | ||
|
||
const verificationResult = await verificationResponse.json(); | ||
|
||
if (verificationResult.success) { | ||
// CAPTCHA verified successfully, proceed with your form processing | ||
return NextResponse.json({ success: true }); | ||
} else { | ||
return NextResponse.json({ success: false, message: 'CAPTCHA verification failed' }, { status: 400 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters