New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createWebhook
always respond 404 with Koa
#1889
Comments
Try with this example: https://github.com/feathers-studio/telegraf-docs/blob/master/examples/webhook/koa.ts |
@hypernova7 example is completely broken. app.use(async (ctx, next) =>
(await bot.createWebhook({ domain: webhookDomain }))(ctx.req, ctx.res, next),
);
|
The original code posted above seems fine. It can only respond 404 if for whatever reason webhook calls next, which means it is not going to handle the request. I'll test and update the example. |
No, I've tested on koa 2.14.2 Handler called and server responds webhook with right body but 404 status. |
Try with bot.launch import 'dotenv/config'
import Koa from 'koa'
import ngrok from 'ngrok';
import { Telegraf } from 'telegraf'
const app = new Koa();
const bot = new Telegraf(process.env.BOT_TOKEN);
const url = await ngrok.connect(8080); // for development
bot.start((ctx) => {
ctx.reply('Hi')
})
bot.launch({
webhook: {
domain: url,
port: 8080,
cb: app
}
}) |
|
The original code creates webhook on each request. But the main problem is that it doesn't work |
|
// create webhook only ONCE
const webhook = await bot.createWebhook({ domain: webhookDomain });
app.use(async (ctx, next) => {
// use ctx.request to have access to body
await webhook(ctx.request, ctx.res, next);
}); But still it responds 404... |
Context
Minimal Example Code Reproducing the Issue
Expected Behavior
200 status code
Current Behavior
404 status code
Error Message and Logs (
export DEBUG='telegraf:*'
)No errors in debug log
The text was updated successfully, but these errors were encountered: