1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

Add support for client app ID routing when serving on a LAN ip address

This commit is contained in:
Andrew Kingston 2020-10-14 20:33:09 +01:00
parent 9f9cc46988
commit 59b12af15c

View file

@ -4,17 +4,20 @@ import { parseAppIdFromCookie } from "./getAppId"
export const screenRouter = ({ screens, onScreenSelected, window }) => { export const screenRouter = ({ screens, onScreenSelected, window }) => {
const makeRootedPath = url => { const makeRootedPath = url => {
if ( const hostname = window.location && window.location.hostname
window.location && if (hostname) {
(window.location.hostname === "localhost" || if (
window.location.hostname === "127.0.0.1") hostname === "localhost" ||
) { hostname === "127.0.0.1" ||
const appId = parseAppIdFromCookie(window.document.cookie) hostname.startsWith("192.168")
if (url) { ) {
if (url.startsWith(appId)) return url const appId = parseAppIdFromCookie(window.document.cookie)
return `/${appId}${url.startsWith("/") ? "" : "/"}${url}` if (url) {
if (url.startsWith(appId)) return url
return `/${appId}${url.startsWith("/") ? "" : "/"}${url}`
}
return appId
} }
return appId
} }
return url return url
} }