diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 326c97e..a349b89 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12,6 +12,7 @@ "@capacitor/camera": "^8.0.0", "@capacitor/cli": "^8.0.0", "@capacitor/core": "^8.0.0", + "@capacitor/http": "^0.0.2", "@capacitor/push-notifications": "^8.0.0", "@capacitor/splash-screen": "^8.0.0", "@capacitor/status-bar": "^8.0.0", @@ -563,6 +564,16 @@ "tslib": "^2.1.0" } }, + "node_modules/@capacitor/http": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@capacitor/http/-/http-0.0.2.tgz", + "integrity": "sha512-3UPqYOmVkAQjCWWowSDGPnBkXY7znbPE7lNs8nhwTmE2E5fXTvjHM8PV15zOyn+nenY7zEu9Air49fGjrX+Tjg==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "license": "MIT", + "dependencies": { + "@capacitor/core": "latest" + } + }, "node_modules/@capacitor/push-notifications": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-8.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index d76aeee..4ef4888 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ "@capacitor/camera": "^8.0.0", "@capacitor/cli": "^8.0.0", "@capacitor/core": "^8.0.0", + "@capacitor/http": "^0.0.2", "@capacitor/push-notifications": "^8.0.0", "@capacitor/splash-screen": "^8.0.0", "@capacitor/status-bar": "^8.0.0", diff --git a/frontend/src/pages/LoginPage.tsx b/frontend/src/pages/LoginPage.tsx index 0117a14..98fa538 100644 --- a/frontend/src/pages/LoginPage.tsx +++ b/frontend/src/pages/LoginPage.tsx @@ -111,25 +111,24 @@ export default function LoginPage() { (window as any).tapCount = 0; setIsLoading(true); try { - // Use native fetch instead of axios for better Capacitor WebView compatibility - const response = await fetch('https://veridian.runfoo.run/api/auth/login', { - method: 'POST', + // Use CapacitorHttp for native-level HTTP requests (bypasses WebView restrictions) + const { CapacitorHttp } = await import('@capacitor/core'); + const response = await CapacitorHttp.post({ + url: 'https://veridian.runfoo.run/api/auth/login', headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json', }, - body: JSON.stringify({ + data: { email: 'tenwest@proton.me', password: '2GreenSlugs!' - }), + }, }); - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(errorData.message || `HTTP ${response.status}`); + if (response.status !== 200) { + throw new Error(response.data?.message || `HTTP ${response.status}`); } - const data = await response.json(); + const data = response.data; login(data.accessToken, data.refreshToken, data.user); navigate('/dashboard'); } catch (err: any) {