mirror of
https://github.com/koush/scrypted.git
synced 2026-03-01 16:52:56 +00:00
26 lines
776 B
TypeScript
26 lines
776 B
TypeScript
import sdk from '@scrypted/sdk';
|
|
|
|
export async function getUrlLocalAdresses(console: Console, url: string) {
|
|
let urls: string[];
|
|
try {
|
|
const addresses = await sdk.endpointManager.getLocalAddresses();
|
|
if (addresses) {
|
|
const [address] = addresses;
|
|
if (address) {
|
|
const u = new URL(url);
|
|
u.hostname = address;
|
|
url = u.toString();
|
|
}
|
|
urls = addresses.map(address => {
|
|
const u = new URL(url);
|
|
u.hostname = address;
|
|
return u.toString();
|
|
});
|
|
}
|
|
}
|
|
catch (e) {
|
|
console.warn('Error determining external addresses. Is Scrypted Server Address configured?', e);
|
|
}
|
|
return urls;
|
|
}
|