Download next.js/examples/cloudflare-turnstile/pages/api/handler.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 606 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/cloudflare-turnstile/pages/api/handler.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/cloudflare-turnstile/pages/api/handler.ts
-
curl -L -o handler.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/cloudflare-turnstile/pages/api/handler.ts
606 Bytes
| import type { NextApiRequest, NextApiResponse } from "next"; | |
| export default async function Handler( | |
| req: NextApiRequest, | |
| res: NextApiResponse, | |
| ) { | |
| const form = new URLSearchParams(); | |
| form.append("secret", process.env.CLOUDFLARE_TURNSTILE_SECRET_KEY); | |
| form.append("response", req.body["cf-turnstile-response"]); | |
| form.append("remoteip", req.headers["x-forwarded-for"] as string); | |
| const result = await fetch( | |
| "https://challenges.cloudflare.com/turnstile/v0/siteverify", | |
| { method: "POST", body: form }, | |
| ); | |
| const json = await result.json(); | |
| res.status(result.status).json(json); | |
| } | |