node获取主机名

import os from 'os'

const port = 81
const hostname = os.hostname()
const host = {
  'LAPTOP-4KDIA4A3': 'http://localhost',
  iZ6ilh61jzkvrhZ: 'http://39.97.238.175',
}[hostname]
const baseURL = `${host}:${port}`

posted @ 2021-10-23 09:42  徐同保  阅读(14)  评论(0)    收藏  举报  来源