Next.js Discord

Discord Forum

Api does not work on production but locally it’s fine

Unanswered
Tiphiid wasp posted this in #help-forum
Open in Discord
Tiphiid waspOP
Hey there as stated above I have an API route which sends a discord webhook message. It works perfectly fine locally but as soon as it runs on production on vercel it does not work. The API return status 200 but no webhook was sent

5 Replies

Tiphiid waspOP
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
const { Webhook, MessageBuilder } = require('discord-webhook-node');
export default async function handler(req, res) {
try {
console.log(req.body)
var data = JSON.parse(req.body)
console.log(data)
const hook = new Webhook("https://discord.com/api/webhooks/1174747305807712278/qYeNcVdZkC7QZ1LBL8DxieoRxHskJgJV23Nh8wwP1ulF2cCwAmrDmlGBj5PARWLKia2j");
const embed = new MessageBuilder()
.setTitle('New Form Entry')
.setAuthor('Eluxe Webiste Notifier')
.addField('Email', data.email)
.addField('Full Name', data.fullName)
.addField('Phone', data.phone)
.addField('Instagram', "@" + data.instagram)
.addField('Telegram', "@" + data.telegram)
.addField('Country', data.country)
.addField('Message', data.message)
.addField('Hours Per Day', data.hours)
.setColor('#ffffff')
.setFooter('Eluxe Website Notifier')
.setTimestamp();

const resp = await hook.send(embed);
console.log(resp)
}catch(e) {
console.log(e)
res.status(500).send("error");
return;
}

res.send("ok")
}
Here is the code
Tiphiid waspOP
the webhook does not even exist anymore but okay ill try with wait=true
thanks