Skip to content

Instantly share code, notes, and snippets.

@andresclua
andresclua / recaptcha_server.js
Last active February 15, 2024 09:11
Recaptcha server example astro
import axios from 'axios';
export const prerender = false;
export const POST = async ({ request }) => {
try {
const requestData = await request.json();
const google_access_token = requestData.google_access_token;
const SECRET_KEY = 'yoursecretkey';
// Make a POST request to Google reCAPTCHA verification API
const response = await axios.post( 'https://www.google.com/recaptcha/api/siteverify',null,
async function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script')
script.setAttribute("src", src)
document.body.appendChild(script)
script.onload = resolve
script.onerror = reject
})
}