fix(android): Use CapacitorHttp for native-level HTTP requests
This commit is contained in:
parent
7159d48b06
commit
bc78836bf6
3 changed files with 21 additions and 10 deletions
11
frontend/package-lock.json
generated
11
frontend/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue