()
| 29 | * 4. Empty string (same origin). |
| 30 | */ |
| 31 | export function resolveApiBase(): string { |
| 32 | const params = new URLSearchParams(window.location.search); |
| 33 | const configured = params.get('api') || localStorage.getItem('space_api_base'); |
| 34 | if (configured) { |
| 35 | return configured.replace(/\/$/, ''); |
| 36 | } |
| 37 | if ( |
| 38 | window.location.protocol === 'file:' || |
| 39 | (window.location.port !== '' && window.location.port !== '5000') |
| 40 | ) { |
| 41 | return 'http://127.0.0.1:5000'; |
| 42 | } |
| 43 | return ''; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Error thrown whenever the server returns a non-2xx status or the request |
no test coverage detected