Telegram bot was showing this error when users tried to view tasks:
TelegramError: 400: Bad Request: inline keyboard button URL 'http://localhost:4000/dashboard' is invalid: Wrong HTTP URL
- Telegram API does NOT accept localhost URLs in inline keyboard buttons
- The bot code was using
process.env.FRONTEND_URL || 'http://localhost:4000'as a fallback - When
FRONTEND_URLwasn't set in .env, it defaulted to localhost, causing the error
Modified the following files to only show inline keyboard buttons when a valid public URL is configured:
src/bot/commands/tasks.js- Admin dashboard buttonsrc/bot/commands/auth.js- Quest dashboard notification to adminsrc/bot/commands/info.js- Profile dashboard buttons
The code now checks:
if (process.env.FRONTEND_URL && !process.env.FRONTEND_URL.includes('localhost')) {
// Only add inline keyboard button if URL is valid
}Added comments in .env file explaining how to configure FRONTEND_URL
- Leave
FRONTEND_URLunset or commented out in.env - Bot will work normally but without dashboard buttons
- Users will see helpful messages instead
Add to your .env file:
FRONTEND_URL=https://yourdomain.com
# or
FRONTEND_URL=https://your-app.onrender.com
# or any other publicly accessible HTTPS URLRequirements:
- ✅ Must be a publicly accessible URL (not localhost)
- ✅ Should use HTTPS (Telegram preference)
- ❌ Cannot be localhost, 127.0.0.1, or internal IP
- ❌ Cannot be HTTP (though may work, HTTPS is recommended)
- Restart your bot application
- Try
/taskscommand in Telegram - Results:
- Without FRONTEND_URL: Works perfectly, shows tasks without dashboard button
- With valid FRONTEND_URL: Shows tasks with clickable dashboard button
# Deployed on Render
FRONTEND_URL=https://taskquest.onrender.com
# Deployed on Heroku
FRONTEND_URL=https://taskquest-app.herokuapp.com
# Custom domain
FRONTEND_URL=https://taskquest.yourdomain.com
# Ngrok tunnel (for temporary testing)
FRONTEND_URL=https://abc123.ngrok.io✅ Bot now works without FRONTEND_URL configured
- All commands function properly
- No more Telegram API errors
- Dashboard buttons only appear when valid URL is set
- Deploy your frontend to a hosting service (Render, Vercel, Netlify, Heroku, etc.)
- Get the public URL
- Add it to
.envasFRONTEND_URL=https://your-url.com - Restart the bot
- Dashboard buttons will automatically appear
- Nothing to do! Bot works perfectly as-is
- Users can still use all bot commands
- Admin functionality works through bot commands
src/bot/commands/tasks.js- Line 77src/bot/commands/auth.js- Line 417src/bot/commands/info.js- Lines 101, 114.env- Added FRONTEND_URL documentation
- The webhook.js file still has localhost for GraphQL, but that's internal server communication (not Telegram-related)
- If you deploy your app, remember to update all localhost references in your config