Try to guess hostname for websocket
This commit is contained in:
parent
8fe33095dd
commit
1bdc2b1438
@ -6,6 +6,7 @@ import Modal from "react-modal";
|
|||||||
import "../assets/stylesheets/cabledetail.scss";
|
import "../assets/stylesheets/cabledetail.scss";
|
||||||
|
|
||||||
Modal.setAppElement("#root");
|
Modal.setAppElement("#root");
|
||||||
|
const hostname = window.location.hostname; // Get the hostname from the URL bar
|
||||||
|
|
||||||
class Cable {
|
class Cable {
|
||||||
constructor(cableData) {
|
constructor(cableData) {
|
||||||
@ -14,7 +15,7 @@ class Cable {
|
|||||||
this.brand = cableData.brand;
|
this.brand = cableData.brand;
|
||||||
this.position = cableData.position;
|
this.position = cableData.position;
|
||||||
this.image = cableData.image
|
this.image = cableData.image
|
||||||
? `http://localhost${cableData.image}`
|
? `http://${hostname}${cableData.image}`
|
||||||
: DefaultPartImg;
|
: DefaultPartImg;
|
||||||
this.dynamicProps = {};
|
this.dynamicProps = {};
|
||||||
this.horizontal = [];
|
this.horizontal = [];
|
||||||
|
@ -12,7 +12,9 @@ const root = ReactDOM.createRoot(document.getElementById("root"));
|
|||||||
|
|
||||||
// Socket handler
|
// Socket handler
|
||||||
console.log("Connecting to WebSocket server.");
|
console.log("Connecting to WebSocket server.");
|
||||||
const socket = new WebSocket("ws://localhost:9000");
|
const hostname = window.location.hostname; // Get the hostname from the URL bar
|
||||||
|
const wsPort = "9000";
|
||||||
|
const socket = new WebSocket(`ws://${hostname}:${wsPort}`);
|
||||||
socket.addEventListener("open", function (event) {
|
socket.addEventListener("open", function (event) {
|
||||||
console.log("Websocket connected.");
|
console.log("Websocket connected.");
|
||||||
console.log("Welcome to Belden Jukebox!");
|
console.log("Welcome to Belden Jukebox!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user