Vercel ID Bot and Contact Form
Unanswered
csdevfe posted this in #help-forum
csdevfeOP
3 Replies
csdevfeOP
/api/route
import { Resend } from "resend";
import { checkBotId } from 'botid/server';
const resend = new Resend(process.env.RESEND_API_KEY);
export default async function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ success: false, error: "Method not allowed" });
}
// Bot protection
try {
const botId = await checkBotId(req);
if (botId) {
return res.status(403).json({ success: false, error: "Bot detected" });
}
} catch (error) {
console.error("Bot ID check error:", error);
return res.status(500).json({ success: false, error: "bot Verification failed" });
}
const { name, email, message, website = "", captchaAnswer, expectedAnswer } = req.body;
// Spam honeypot
if (website.trim() !== "") return res.status(400).json({ success: false, error: "Spam detected" });
// Captcha check
if (parseInt(captchaAnswer) !== expectedAnswer) return res.status(400).json({ success: false, error: "Captcha incorrect" });
// Required fields
if (!name !email !message) return res.status(400).json({ success: false, error: "Missing required fields" });
try {
// Notify site owner
await resend.emails.send({
from: process.env.RESEND_FROM,
to: process.env.CONTACT_TO,
reply_to: email,
subject:
html:
});
return res.status(200).json({ success: true });
} catch (err) {
console.error("Resend API Error:", err);
return res.status(500).json({ success: false, error: "Server error" });
}
}
import { Resend } from "resend";
import { checkBotId } from 'botid/server';
const resend = new Resend(process.env.RESEND_API_KEY);
export default async function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ success: false, error: "Method not allowed" });
}
// Bot protection
try {
const botId = await checkBotId(req);
if (botId) {
return res.status(403).json({ success: false, error: "Bot detected" });
}
} catch (error) {
console.error("Bot ID check error:", error);
return res.status(500).json({ success: false, error: "bot Verification failed" });
}
const { name, email, message, website = "", captchaAnswer, expectedAnswer } = req.body;
// Spam honeypot
if (website.trim() !== "") return res.status(400).json({ success: false, error: "Spam detected" });
// Captcha check
if (parseInt(captchaAnswer) !== expectedAnswer) return res.status(400).json({ success: false, error: "Captcha incorrect" });
// Required fields
if (!name !email !message) return res.status(400).json({ success: false, error: "Missing required fields" });
try {
// Notify site owner
await resend.emails.send({
from: process.env.RESEND_FROM,
to: process.env.CONTACT_TO,
reply_to: email,
subject:
New message from ${name},html:
<p><strong>Name:</strong> ${name}</p>
<p><strong>Email:</strong> ${email}</p>
<p><strong>Message:</strong></p>
<pre>${message}</pre>,});
return res.status(200).json({ success: true });
} catch (err) {
console.error("Resend API Error:", err);
return res.status(500).json({ success: false, error: "Server error" });
}
}
Error with contact form
Asked chatGPT
Contact form for my other projects works and I can see the request made in resend dashboard under my account.
here is the other sites and submit the form and it will send. DO NOT SPAM. kylepprofile.dev
Asked chatGPT
Contact form for my other projects works and I can see the request made in resend dashboard under my account.
here is the other sites and submit the form and it will send. DO NOT SPAM. kylepprofile.dev
Are there vercel ID Bot API key? in the vercel dashboard under hte firewall?