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