- import { networkInterfaces } from 'os';
- export function getLocalIp(): string {
- const ips = networkInterfaces();
- let ip;
- Object.values(ips).forEach(el => {
- const matchIp = el?.find(element => element.family === 'IPv4');
- if (matchIp && matchIp.address !== '127.0.0.1') {
- ip = matchIp.address;
- }
- });
- return ip;
- }
|