-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (29 loc) · 1.12 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// import express from 'express';
// import bodyParser from 'body-parser';
// import fetch from 'node-fetch';
// const app = express();
// const PORT = process.env.PORT || 3000;
// const RECAPTCHA_SECRET_V3 = 'YOUR_RECAPTCHA_V3_SECRET_KEY';
// const RECAPTCHA_SECRET_V2 = 'YOUR_RECAPTCHA_V2_SECRET_KEY';
// app.use(bodyParser.json());
// app.post('/verify-recaptcha', async (req, res) => {
// const { token, version } = req.body;
// const secretKey = version === 'v3' ? RECAPTCHA_SECRET_V3 : RECAPTCHA_SECRET_V2;
// try {
// const response = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// },
// body: `secret=${secretKey}&response=${token}`,
// });
// const data = await response.json();
// res.json(data);
// } catch (error) {
// console.error('Error verifying reCAPTCHA:', error);
// res.status(500).json({ success: false, error: 'Failed to verify reCAPTCHA' });
// }
// });
// app.listen(PORT, () => {
// console.log(`Server is running on port ${PORT}`);
// });