Open Arjun021 opened 1 year ago
You need to make sure the URL you're saving on Discord has /interactions at the end.
So don't just post https://asdfasdfasdfasd.ngrok.io, make sure it's https://asdfasdfasdfasd.ngrok.io/interactions
I'm getting a similar error message. I added /interactions
on the end of my ngrok url I put in the discord endpoint url app setting.
Error: Bad request signature
at <path>/discord-example-app/utils.js:13:13
at <path>\discord-example-app\node_modules\body-parser\lib\read.js:111:9
at AsyncResource.runInAsyncScope (node:async_hooks:204:9)
at invokeCallback (<path>\discord-example-app\node_modules\raw-body\index.js:231:16)
at done (<path>\discord-example-app\node_modules\raw-body\index.js:220:7)
at IncomingMessage.onEnd (<path>\discord-example-app\node_modules\raw-body\index.js:280:7)
at IncomingMessage.emit (node:events:513:28)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Turns out my problem was that I copied the wrong token into DISCORD_TOKEN
in .env
. Once I copied the right thing it worked.
I am currently experiencing this problem, where did you find the correct token? It provided me with one, which I assumed was the right one...but perhaps not.
Turns out my problem was that I copied the wrong token into
DISCORD_TOKEN
in.env
. Once I copied the right thing it worked.
I have a similar issue, but this doesn't fix it.
Turns out my problem was that I copied the wrong token into
DISCORD_TOKEN
in.env
. Once I copied the right thing it worked.I have a similar issue, but this doesn't fix it.
Have you already solved this issue?
I'm also facing the same issue. I have outputted the relevant parameters and confirmed that the configurations are correct.
Turns out my problem was that I copied the wrong token into
DISCORD_TOKEN
in.env
. Once I copied the right thing it worked.I have a similar issue, but this doesn't fix it.
Have you already solved this issue?
I started from scratch, so in a way, yes, but I didn't solve the issue itself.
In my case, .env was not loaded correctly. I'm not sure it helps you, but here's my situation:
I was running app on docker compose, since I wanted to use it with cloudflare tunnel. Here's part of my docker-compose.yml, which did not work correctly:
version: '3.1'
services:
app:
image: node:latest
command: node /app/app.js # this is not good. this way of invoking app.js won't load .env in the project root.
volumes:
- ./:/app/
tunnel:
image: cloudflare/cloudflared
command: tunnel run
...
as written in comment, the way starting the server was not good. and this is the config which worked correctly:
version: '3.1'
services:
app:
image: node:latest
working_dir: /app
command: node app.js
volumes:
- ./:/app/
tunnel:
image: cloudflare/cloudflared
command: tunnel run
...
Hope this helps someone :)
I have problems registering* the INTERACTIONS ENDPOINT URL for on the Discord Bot Developer page.
There seemed to be a problem with the security-and-auth part (see discord developer doc link below).
These didn't work for me (and I used the debugger to check the values)
const isValidRequest = verifyKey(req.rawBody, signature, timestamp, 'MY_CLIENT_PUBLIC_KEY');
import nacl from 'tweetnacl'; nacl.sign.detached.verify(xxx)
from https://discord.com/developers/docs/interactions/receiving-and-responding#security-and-authorizationWhat worked was this using the verifyKeyMiddleware:
import { verifyKeyMiddleware } from 'discord-interactions';
app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async function (req, res) {
After running the example and running local server with ngrok . I set the URL in discord settings according to the doc but after that I am getting Bad request signature error.
It's coming from the utils.js file
VerifyDiscordRequest
function. How can we resolve this issue ?