shrink imagies
This commit is contained in:
parent
8457604da7
commit
a6022d31c6
9 changed files with 131 additions and 39 deletions
|
@ -1,28 +0,0 @@
|
|||
import os from 'node:os'
|
||||
|
||||
/**
|
||||
* Get the private IP addr of the dev machine to use as the API url.
|
||||
* This is preferred to using localhost or 0.0.0.0 because it allows
|
||||
* us to use the dev client from other devices (i.e. phones)
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getLocalApiUrl() {
|
||||
const addresses = Object.values(os.networkInterfaces())
|
||||
.flat()
|
||||
.filter((addr) => !addr.internal)
|
||||
.filter((addr) => addr.family === 'IPv4')
|
||||
.map((addr) => addr.address)
|
||||
|
||||
let address = addresses.find((addr) => addr.startsWith('192.168')) ?? addresses.at(0)
|
||||
|
||||
if (address === undefined) {
|
||||
console.warn("Couldn't identify the local address for the server. falling back to localhost")
|
||||
address = 'localhost'
|
||||
}
|
||||
|
||||
if (addresses.length > 1) {
|
||||
console.warn(`chose API URL ${address} from possible choices: ${addresses.join(', ')}`)
|
||||
}
|
||||
|
||||
return `http://${address}:7295`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue