diff --git a/src/hub.js b/src/hub.js index cf096150c926e89d4999d87cd0ff34210dc73cd3..cf0f0582858c04091acb3578f1f0da0d9bee79ad 100644 --- a/src/hub.js +++ b/src/hub.js @@ -302,8 +302,9 @@ const onReady = async () => { console.log(`Hub ID: ${hubId}`); const socketProtocol = document.location.protocol === "https:" ? "wss:" : "ws:"; - const socketPort = qs.phx_port || document.location.port; - const socketHost = qs.phx_host || document.location.hostname; + const socketPort = qs.phx_port || (process.env.NODE_ENV === "production" ? document.location.port : 443); + const socketHost = + qs.phx_host || (process.env.NODE_ENV === "production" ? document.location.hostname : "dev.reticulum.io"); const socketUrl = `${socketProtocol}//${socketHost}${socketPort ? `:${socketPort}` : ""}/socket`; console.log(`Phoenix Channel URL: ${socketUrl}`); diff --git a/src/react-components/hub-create-panel.js b/src/react-components/hub-create-panel.js index 32fd19b4edfcb343b0cada0d4f0abf0052344d8e..0caff0292001ee18d9ef247d160915cd59b1f273 100644 --- a/src/react-components/hub-create-panel.js +++ b/src/react-components/hub-create-panel.js @@ -38,14 +38,25 @@ class HubCreatePanel extends Component { hub: { name: this.state.name, default_environment_gltf_bundle_url: environment.bundle_url } }; - const res = await fetch("/api/v1/hubs", { + let createUrl = "/api/v1/hubs"; + + if (process.env.NODE_ENV === "development") { + createUrl = `https://dev.reticulum.io${createUrl}`; + } + + const res = await fetch("https://dev.reticulum.io/api/v1/hubs", { body: JSON.stringify(payload), headers: { "content-type": "application/json" }, method: "POST" }); const hub = await res.json(); - document.location = hub.url; + + if (process.env.NODE_ENV === "production") { + document.location = hub.url; + } else { + document.location = `/hub.html?hub_id=${hub.hub_id}`; + } }; isHubNameValid = () => { diff --git a/webpack.config.js b/webpack.config.js index 4f9b26d26cab4c3959a5b1796696f7a0b531c086..744ae07283f4c8464ac071fd2f71d4a44fee4b3d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -87,7 +87,7 @@ const config = { mode: "development", devtool: process.env.NODE_ENV === "production" ? "source-map" : "inline-source-map", devServer: { - open: true, + open: false, https: createHTTPSConfig(), host: "0.0.0.0", useLocalIp: true,