display url to open local + network in dev!
This commit is contained in:
parent
9a8a8273cf
commit
ffbb5d7e75
3 changed files with 34 additions and 1 deletions
|
|
@ -117,6 +117,9 @@
|
|||
"vitest": "^0.34.6",
|
||||
"yaml": "^2.3.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"systeminformation": "^5.21.22"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"three": "0.128.0",
|
||||
|
|
|
|||
13
pnpm-lock.yaml
generated
13
pnpm-lock.yaml
generated
|
|
@ -144,6 +144,10 @@ importers:
|
|||
workbox-build:
|
||||
specifier: ^7.0.0
|
||||
version: 7.0.0
|
||||
optionalDependencies:
|
||||
systeminformation:
|
||||
specifier: ^5.21.22
|
||||
version: 5.21.22
|
||||
devDependencies:
|
||||
'@storybook/addon-essentials':
|
||||
specifier: ^7.4.6
|
||||
|
|
@ -13417,6 +13421,15 @@ packages:
|
|||
resolution: {integrity: sha512-AsS729u2RHUfEra9xJrE39peJcc2stq2+poBXX8bcM08Y6g9j/i/PUzwNQqkaJde7Ntg1TO7bSREbR5sdosQ+g==}
|
||||
dev: true
|
||||
|
||||
/systeminformation@5.21.22:
|
||||
resolution: {integrity: sha512-gNHloAJSyS+sKWkwvmvozZ1eHrdVTEsynWMTY6lvLGBB70gflkBQFw8drXXr1oEXY84+Vr9tOOrN8xHZLJSycA==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
os: [darwin, linux, win32, freebsd, openbsd, netbsd, sunos, android]
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/tabbable@6.2.0:
|
||||
resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}
|
||||
dev: false
|
||||
|
|
|
|||
19
server.js
19
server.js
|
|
@ -7,6 +7,10 @@ const path = require('path')
|
|||
const cors = require('cors')
|
||||
const https = require('https')
|
||||
const fs = require('fs')
|
||||
let siModule
|
||||
try {
|
||||
siModule = require('systeminformation')
|
||||
} catch (err) { }
|
||||
|
||||
// Create our app
|
||||
const app = express()
|
||||
|
|
@ -44,8 +48,21 @@ const port = (require.main === module ? process.argv[2] : portArg !== -1 ? proce
|
|||
// Start the server
|
||||
const server = isProd ?
|
||||
undefined :
|
||||
app.listen(port, function () {
|
||||
app.listen(port, async function () {
|
||||
console.log('Server listening on port ' + server.address().port)
|
||||
if (siModule) {
|
||||
const _interfaces = await siModule.networkInterfaces()
|
||||
const interfaces = Array.isArray(_interfaces) ? _interfaces : [_interfaces]
|
||||
let netInterface = interfaces.find(int => int.default)
|
||||
if (!netInterface) {
|
||||
netInterface = interfaces.find(int => !int.virtual) ?? interfaces[0]
|
||||
console.warn('Failed to get the default network interface, searching for fallback')
|
||||
}
|
||||
if (netInterface) {
|
||||
const address = netInterface.ip4
|
||||
console.log(`You can access the server on http://localhost:8080 or http://${address}:${port}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = { app }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue