Фикс бага аутентификации в tg mini app
Собранный в replit протатип. При попытке аутентификации в TG mini app выдает ошибку что initdata прилетает пустая.
Bug Description: Telegram Mini App Authentication Failure
Framework: Flask with aiogram
Symptoms:
- Server logs show "Init data received (length: 0)"- Auth validation fails with "Empty init data received" warning- Users see "Please open this app through Telegram" error message- Problem persists even when accessing through Telegram's interface
Technical Context:
The app uses Telegram's WebApp authentication protocol which requires:
- initData from Telegram.WebApp- Hash validation using bot token- User data extraction from validated initData
Current Implementation:
- Frontend (base.html) attempts to get initData from window.Telegram.WebApp- Backend (auth.py) expects initData in headers or query parameters- Bot (bot.py) sets up WebApp with production URL
Reproduction Steps:
- Start bot with /start command- Click WebApp button
- Observe browser console for initData logs- Check server logs for validation attempts
Impact:
- No users can access the journal functionality- Authentication fails 100% of the time- Core app functionality completely blocked