From 59b12af15c87591f3a1800970a0582fb53a7b079 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 14 Oct 2020 20:33:09 +0100 Subject: [PATCH] Add support for client app ID routing when serving on a LAN ip address --- packages/client/src/render/screenRouter.js | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/client/src/render/screenRouter.js b/packages/client/src/render/screenRouter.js index fb84248d94..14337c4319 100644 --- a/packages/client/src/render/screenRouter.js +++ b/packages/client/src/render/screenRouter.js @@ -4,17 +4,20 @@ import { parseAppIdFromCookie } from "./getAppId" export const screenRouter = ({ screens, onScreenSelected, window }) => { const makeRootedPath = url => { - if ( - window.location && - (window.location.hostname === "localhost" || - window.location.hostname === "127.0.0.1") - ) { - const appId = parseAppIdFromCookie(window.document.cookie) - if (url) { - if (url.startsWith(appId)) return url - return `/${appId}${url.startsWith("/") ? "" : "/"}${url}` + const hostname = window.location && window.location.hostname + if (hostname) { + if ( + hostname === "localhost" || + hostname === "127.0.0.1" || + hostname.startsWith("192.168") + ) { + const appId = parseAppIdFromCookie(window.document.cookie) + if (url) { + if (url.startsWith(appId)) return url + return `/${appId}${url.startsWith("/") ? "" : "/"}${url}` + } + return appId } - return appId } return url }