tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.38k stars 2.58k forks source link

[bug] Cannot connect android device to local nor remote server #11770

Open moubarak opened 14 hours ago

moubarak commented 14 hours ago

Describe the bug

Android app is calling localhost instead of my local server's ip. I followed the tauri documentation and setup the frontend, vite.cofig, tauri.conf.json based on that. I'm running using pnpm tauri android dev --host. Calling the remote server gives me another error even though I allowed tauri:localhost origin.

Access to XMLHttpRequest at 'https://api.lttlbrd.app/version_info' from origin 'http://tauri.localhost/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

On iOS everything works fine. Non of the relevant issues provide a solution.

Reproduction

No response

Expected behavior

Calls to localhost should be routed to my local server's ip

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.1.1 x86_64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 22.11.0
    - pnpm: 9.13.2
    - npm: 10.9.0

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.0
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-store 🦀: 2.1.0
    - @tauri-apps/plugin-store : 2.1.0
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.2
    - tauri-plugin-log 🦀: 2.0.2
    - @tauri-apps/plugin-log : 2.0.0
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1
    - tauri-plugin-global-shortcut 🦀: 2.0.1
    - @tauri-apps/plugin-global-shortcut : 2.0.0

[-] App
    - build-type: bundle
    - CSP: 
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

Device running Android 14