ss_website/components/ServerActions.ts

14 lines
366 B
TypeScript
Raw Normal View History

2024-05-16 05:19:03 +00:00
"use server"
import axios from "axios"
export async function verifyCaptcha(token: string | null) {
const res = await axios.post(
`https://www.google.com/recaptcha/api/siteverify?secret=${process.env.NEXT_PUBLIC_RECAPTCHA_SECRET_KEY}&response=${token}`
)
if (res.data.success) {
return "success!"
} else {
throw new Error("Failed Captcha")
}
}