( input: RequestInfo | URL, init?: RequestInit )
| 238 | * This elegantly covers all cases: localhost, LAN IPs, custom network setups. |
| 239 | */ |
| 240 | export const platformFetch = async ( |
| 241 | input: RequestInfo | URL, |
| 242 | init?: RequestInit |
| 243 | ): Promise<Response> => { |
| 244 | const url = typeof input === 'string' |
| 245 | ? input |
| 246 | : input instanceof URL |
| 247 | ? input.href |
| 248 | : input.url; |
| 249 | |
| 250 | // HTTP (not HTTPS) = likely local/private network |
| 251 | const isHttp = url.startsWith('http://'); |
| 252 | |
| 253 | if (isTauri() && isHttp && tauriFetchFn) { |
| 254 | Logger.debug('platform', `Using Tauri HTTP for: ${url}`); |
| 255 | return tauriFetchFn(input as any, init as any); |
| 256 | } |
| 257 | |
| 258 | // Use regular fetch for HTTPS and web |
| 259 | return fetch(input, init); |
| 260 | }; |
| 261 | |
| 262 | /** |
| 263 | * Open a URL outside the app. Tauri webviews (especially mobile) ignore |
no test coverage detected