Skip to content

Commit b5a3ae7

Browse files
committed
chore: payload update
1 parent 52fdc66 commit b5a3ae7

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/services/captcha.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import axios from 'axios';
2-
31
export 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
}

0 commit comments

Comments
 (0)