For study purposes I'm trying to create a Telegram bot on pure Node.JS, without any additional NPM's. I host it on glitch.com. Here's a very basic code sample:
require('https').createServer((req, res) => {
if(req.method == 'POST' && req.url == process.env.SECRET_PATH){
console.log('The webhook was accessed.');
}
res.writeHead(200);
res.end('OK');
}).listen(8443);
I tried listening on different ports (3000, 5000, 8000, 8080, 8443, 80, 88, 443) or several of them simultaneously, used different server modules (http, https), and even tried generating a self-signed certificate. Nothing works.
The request to https://api.telegram.org/bot<TOKEN>/getWebHookInfo returns this:
{
ok: true,
result: {
url: '<WEBHOOK_URL>',
has_custom_certificate: false,
pending_update_count: 4,
last_error_date: 1651148554,
last_error_message: 'Wrong response from the webhook: 403 Forbidden',
max_connections: 40,
ip_address: '18.205.205.44'
}
}
The last_error_message property is always 'Wrong response from the webhook: 403 Forbidden'. What am I doing wrong?