Skip to content

Adding captchas via cloudflare

Course: Rate limitting, DDoS and Captcha - chapter 9

import { Turnstile } from '@marsidev/react-turnstile'
import './App.css'
import axios from 'axios'
import { useState } from 'react'
function App() {
const [token, setToken] = useState<string>("")
return (
<>
<input placeholder='OTP'></input>
<input placeholder='New password'></input>
<Turnstile onSuccess={(token) => {
setToken(token)
}} siteKey='0x4AAAAAAAXtEe2JIeAEUcjX' />
<button onClick={() => {
axios.post("http://localhost:3000/reset-password", {
email: "harkirat@gmail.com",
otp: "123456",
token: token,
})
}}>Update password</button>
</>
)
}
export default App
  • Update the backend code
$1b