Adding captchas via cloudflare
Course: Rate limitting, DDoS and Captcha - chapter 9
- Add a new site to turnstile
- Keep your site key and site secret safe
- Create a react project
- Add https://github.com/marsidev/react-turnstile
- Update
App.tsx
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