Skip to content

Commit 43a008d

Browse files
authored
Update dev-server.js (#5129)
For using local network for other devices.
1 parent 4a2bd04 commit 43a008d

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/dev-server.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import http from 'http';
22
import fs from 'fs';
33
import path from 'path';
44
import { fileURLToPath } from 'url';
5+
import os from 'os';
56

67
const __filename = fileURLToPath(import.meta.url);
78
const __dirname = path.dirname(__filename);
@@ -144,7 +145,7 @@ const server = http.createServer((req, res) => {
144145
});
145146
});
146147

147-
server.listen(PORT, () => {
148+
server.listen(PORT, '0.0.0.0', () => {
148149
console.log(`\n======================================================`);
149150
console.log(`✅ [modelviewer.dev] Local Dev Server is Running!`);
150151
console.log(`======================================================\n`);
@@ -153,5 +154,15 @@ server.listen(PORT, () => {
153154
console.log(`- model-viewer: ${versions.modelViewer}`);
154155
console.log(`- postprocessing: ${versions.postprocessing}\n`);
155156
console.log(`The server is currently listening for connections.`);
156-
console.log(`👉 PLEASE OPEN YOUR BROWSER TO: http://localhost:${PORT}/ \n`);
157+
console.log(`👉 Local: http://localhost:${PORT}/`);
158+
159+
const interfaces = os.networkInterfaces();
160+
for (const name of Object.keys(interfaces)) {
161+
for (const iface of interfaces[name]) {
162+
if (iface.family === 'IPv4' && !iface.internal) {
163+
console.log(`👉 Network: http://${iface.address}:${PORT}/`);
164+
}
165+
}
166+
}
167+
console.log(`\n`);
157168
});

0 commit comments

Comments
 (0)