DEV Community

Discussion on: Discord Webhook Powered Contact Form

Collapse
 
girattlegfx profile image
David Ackerman

When I tried using this I kept getting a cors error not allowing me to post the webhook message in my server. I talked to my friend and he said i'd have to do it with traditional code not next.js, and I'd have to do something like:

const { WebhookClient } = require("discord.js");
const hook = WebhookClient({id: "ID", token: "TOKEN" });
hook.send({});

but idk what im doing lol. Do you know how to get around the cors error without having to rewrite all the code?

Collapse
 
mistval profile image
Randall

You're having CORS errors from the POST request to the Discord webhook? I wouldn't expect that but it's possible something has changed on Discord's side. In this case an opaque response should be fine, so if you just add mode: 'no-cors' to the fetch request, that may resolve your issue.

Collapse
 
girattlegfx profile image
David Ackerman

Oh okay, cool. How exactly do I do that?

Thread Thread
 
girattlegfx profile image
David Ackerman

NVM on that lol, i got it but now im getting a 403 error. Which made me think, if i am not allowed to use the link why not just call the webhook id and token using discord.js xD not sure if it'll work but imma try lol. Thanks for your help! And the article 😂