From f1e951d4d1fcf11a400d7acd3d72ef30ff767c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Almeida?= Date: Sun, 8 Mar 2026 14:11:00 +0000 Subject: [PATCH] feat: use network IP and location.host instead of hardcoded localhost Replace hardcoded localhost references with the actual LAN IP on the server side and location.host on the client side, allowing access to the installer from other devices on the same network. --- client/services/tizenbrew-installer-service/index.js | 9 +++++++-- client/ui/src/app.jsx | 3 ++- client/ui/src/components/WebSocketClient.js | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/services/tizenbrew-installer-service/index.js b/client/services/tizenbrew-installer-service/index.js index 49801c4..7f20d3a 100644 --- a/client/services/tizenbrew-installer-service/index.js +++ b/client/services/tizenbrew-installer-service/index.js @@ -15,7 +15,7 @@ module.exports.onStart = function () { const { join, dirname } = require('path'); const { parsePackage, installPackage } = require('./utils/PackageInstallation.js'); const { Connection, Events } = require('./utils/wsCommunication.js'); - const { homedir } = require('os'); + const { homedir, networkInterfaces } = require('os'); const AccessInfoHTMLPage = require('./utils/HTMLPage.js'); const PushFile = require('./utils/FilePusher.js'); @@ -33,7 +33,12 @@ module.exports.onStart = function () { const app = express(); if (!isTV) { // Enable static file serving for frontend - console.log('Open up http://localhost:8091/ui/dist/index.html to access the TizenBrew Installer.'); + const exposedAddress = + Object.values(networkInterfaces()) + .flat() + .filter(networkInterface => !networkInterface.internal)[0] + .address; // Get the first non-internal network interface IP address + console.log(`Open up http://${exposedAddress}:8091/ui/dist/index.html to access the TizenBrew Installer.`); if (existsSync(`${process.platform === 'win32' ? 'C:\\' : '/'}snapshot/client`)) { app.use(express.static(`${process.platform === 'win32' ? 'C:\\' : '/'}snapshot/client`)); } else app.use(express.static(join(__dirname, '../../'))); diff --git a/client/ui/src/app.jsx b/client/ui/src/app.jsx index 93974e6..8cda537 100644 --- a/client/ui/src/app.jsx +++ b/client/ui/src/app.jsx @@ -74,7 +74,8 @@ export default function App() { function startService(context) { - const testWS = new WebSocket('ws://localhost:8091'); + const host = location?.host ?? 'localhost:8091'; + const testWS = new WebSocket(`ws://${host}`); testWS.onerror = () => { const pkgId = tizen.application.getCurrentApplication().appInfo.packageId; diff --git a/client/ui/src/components/WebSocketClient.js b/client/ui/src/components/WebSocketClient.js index cc0c323..71219df 100644 --- a/client/ui/src/components/WebSocketClient.js +++ b/client/ui/src/components/WebSocketClient.js @@ -12,7 +12,8 @@ const Events = { class Client { constructor(context) { this.context = context; - this.socket = new WebSocket('ws://localhost:8091'); + const host = location?.host ?? 'localhost:8091'; + this.socket = new WebSocket(`ws://${host}`); this.socket.onopen = this.onOpen.bind(this); this.socket.onmessage = this.onMessage.bind(this); this.socket.onerror = () => location.reload();