I’m trying to make code that can send a message to a discord webhook through a browser console but I can’t get it to work
I tried this, as well as some reddit threads and reading the docs
Edit: I also tried using a referrer and origin header with no success
fetch('https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'hello world'
})
});
I’m getting a POST 400 error but i cant for the life of me figure out why
(Yes im using an actual URL when i try the code)
POST https://discord.com/api/webhooks/[ID/TOKEN] 400
(anonymous) @ 00a5b07b3b8bf783d65a.js:153
(anonymous) @ VM234:1
{"message": "Invalid request origin", "code": 50067}
2
Answers
Discord doesn't allow webhook requests from their own site for security reasons My best guess is that they dont want people to be able to send discord cookies with a webhook
You can always check this website for help
https://discohook.org/
For example I tried one and checked the network request that was fired upon the webhook send was something like this.
So maybe
embeds:null
andattachments:[]
is required in the body