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:
I'm a coder who has worn a lot of hats, from individual contributor to lead engineer to "CTO" (yes, in quotes, make of that what you will!). I've a lot to learn and hopefully some to share as well.
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.
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 😂
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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?
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 thefetch
request, that may resolve your issue.Oh okay, cool. How exactly do I do that?
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 😂