File tree Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change 1- import axios from 'axios' ;
2-
31export interface CaptchaResponse {
42 success : boolean ;
53 challenge_ts : string ;
@@ -12,19 +10,17 @@ export async function verifyCaptcha(
1210 captchaToken : string ,
1311 requestorIp : string ,
1412) : Promise < CaptchaResponse > {
15- const payload = {
16- secret : captchaSecret ,
17- response : captchaToken ,
18- remoteip : requestorIp ,
19- } ;
20-
21- console . log ( 'payload' , payload ) ;
13+ const formData = new FormData ( ) ;
14+ formData . append ( 'secret' , captchaSecret ) ;
15+ formData . append ( 'response' , captchaToken ) ;
16+ formData . append ( 'remoteip' , requestorIp ) ;
2217
23- const response = await axios . post < CaptchaResponse > (
24- `https://challenges.cloudflare.com/turnstile/v0/siteverify` ,
25- payload ,
26- ) ;
27- const captchaResult = response . data ;
18+ const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify' ;
19+ const response = await fetch ( url , {
20+ body : formData ,
21+ method : 'POST' ,
22+ } ) ;
23+ const captchaResult = await response . json ( ) ;
2824 console . log ( 'captchaResult' , captchaResult ) ;
29- return captchaResult ;
25+ return captchaResult as CaptchaResponse ;
3026}
You can’t perform that action at this time.
0 commit comments