Fix Android app connectivity issues and add detailed logging

- Add CORS headers to backend server to allow mobile app requests
- Implement request timeout (10s) in capacitor-bridge.js to prevent hanging
- Add comprehensive logging throughout authentication flow
- Add detailed error reporting in initApp for better debugging
- Log all API requests with request IDs for traceability

This fixes the 'Loading Plugin Compass...' infinite loop issue caused by
missing CORS headers and unhandled network timeouts.
This commit is contained in:
southseact-3d
2026-02-17 10:20:11 +00:00
parent 103951eb3c
commit 0c954449d3
3 changed files with 121 additions and 11 deletions

View File

@@ -610,28 +610,48 @@ async function createMobileIndex() {
// Initialize app
async function initApp() {
console.log('[APP] Initializing...');
console.log('[APP] ===========================================');
console.log('[APP] Starting app initialization...');
console.log('[APP] Current time:', new Date().toISOString());
console.log('[APP] User agent:', navigator.userAgent);
console.log('[APP] Platform:', navigator.platform);
try {
// Check if user is authenticated
console.log('[APP] Step 1/4: Checking authentication...');
const authenticated = await isAuthenticated();
console.log('[APP] Authenticated:', authenticated);
console.log('[APP] Step 1/4 complete - Authenticated:', authenticated);
if (authenticated) {
console.log('[APP] Step 2/4: Getting current user...');
const user = await getCurrentUser();
console.log('[APP] Step 2/4 complete - User:', user ? user.email || user.id : 'null');
console.log('[APP] Step 3/4: Checking onboarding status...');
const onboardingDone = await isOnboardingComplete();
console.log('[APP] Step 3/4 complete - Onboarding done:', onboardingDone);
if (!onboardingDone) {
console.log('[APP] Step 4/4: Showing onboarding screen');
showScreen('onboarding');
} else {
console.log('[APP] Step 4/4: Showing main screen');
showScreen('main');
updateWelcome(user);
}
} else {
console.log('[APP] Step 2/2: User not authenticated, showing auth screen');
showScreen('auth');
}
console.log('[APP] ===========================================');
console.log('[APP] Initialization complete!');
} catch (error) {
console.error('[APP] Initialization error:', error);
console.error('[APP] ===========================================');
console.error('[APP] FATAL: Initialization error:', error);
console.error('[APP] Error name:', error.name);
console.error('[APP] Error message:', error.message);
console.error('[APP] Error stack:', error.stack);
console.error('[APP] ===========================================');
showScreen('auth');
}
}
@@ -747,6 +767,10 @@ async function createMobileIndex() {
// Event listeners
document.addEventListener('DOMContentLoaded', () => {
console.log('[APP] ===========================================');
console.log('[APP] DOMContentLoaded event fired!');
console.log('[APP] Starting app in 500ms...');
console.log('[APP] ===========================================');
// Auth form - Sign In
const authSubmitBtn = document.getElementById('auth-submit');
const authSignupBtn = document.getElementById('auth-signup');