mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
replaces all hostname:port usages with authority variable
This commit is contained in:
parent
056c02c5a5
commit
ccd6447869
@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useEffect, useReducer, useState } from "react";
|
import { useCallback, useEffect, useReducer, useState } from "react";
|
||||||
import { Navbar, Form, Offcanvas, Container } from "react-bootstrap";
|
import { Navbar, Form, Offcanvas, Container } from "react-bootstrap";
|
||||||
import { hostname, port, socket } from "./socket";
|
import { authority, socket } from "./socket";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import {
|
import {
|
||||||
Notifications,
|
Notifications,
|
||||||
@ -68,12 +68,12 @@ const App = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Allow the user to add a custom css file
|
// Allow the user to add a custom css file
|
||||||
fetch(`http://${hostname}:${port}/custom.css`)
|
fetch(`http://${authority}/custom.css`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
// If the file exists, create a link element for the custom CSS
|
// If the file exists, create a link element for the custom CSS
|
||||||
const link = document.createElement("link");
|
const link = document.createElement("link");
|
||||||
link.href = `http://${hostname}:${port}/custom.css`;
|
link.href = `http://${authority}/custom.css`;
|
||||||
link.type = "text/css";
|
link.type = "text/css";
|
||||||
link.rel = "stylesheet";
|
link.rel = "stylesheet";
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
@ -83,7 +83,7 @@ const App = () => {
|
|||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
// Fetch data from the API when the client connects
|
// Fetch data from the API when the client connects
|
||||||
fetch(`http://${hostname}:${port}/service-properties`)
|
fetch(`http://${authority}/service-properties`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: State) => {
|
.then((data: State) => {
|
||||||
dispatch({ type: "SET_DATA", data });
|
dispatch({ type: "SET_DATA", data });
|
||||||
@ -91,7 +91,7 @@ const App = () => {
|
|||||||
|
|
||||||
document.title = data.name; // Setting browser tab title
|
document.title = data.name; // Setting browser tab title
|
||||||
});
|
});
|
||||||
fetch(`http://${hostname}:${port}/web-settings`)
|
fetch(`http://${authority}/web-settings`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: Record<string, WebSetting>) => setWebSettings(data));
|
.then((data: Record<string, WebSetting>) => setWebSettings(data));
|
||||||
setConnectionStatus("connected");
|
setConnectionStatus("connected");
|
||||||
|
@ -2,10 +2,10 @@ import { io } from "socket.io-client";
|
|||||||
import { serializeDict, serializeList } from "./utils/serializationUtils";
|
import { serializeDict, serializeList } from "./utils/serializationUtils";
|
||||||
import { SerializedObject } from "./types/SerializedObject";
|
import { SerializedObject } from "./types/SerializedObject";
|
||||||
|
|
||||||
export const hostname =
|
const hostname =
|
||||||
process.env.NODE_ENV === "development" ? `localhost` : window.location.hostname;
|
process.env.NODE_ENV === "development" ? `localhost` : window.location.hostname;
|
||||||
export const port =
|
const port = process.env.NODE_ENV === "development" ? 8001 : window.location.port;
|
||||||
process.env.NODE_ENV === "development" ? 8001 : window.location.port;
|
|
||||||
// Get the forwarded prefix from the global variable
|
// Get the forwarded prefix from the global variable
|
||||||
export const forwardedPrefix: string =
|
export const forwardedPrefix: string =
|
||||||
(window as any) /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
(window as any) /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
||||||
@ -15,7 +15,6 @@ export const authority = `${hostname}:${port}${forwardedPrefix}`;
|
|||||||
|
|
||||||
const URL = `ws://${hostname}:${port}/`;
|
const URL = `ws://${hostname}:${port}/`;
|
||||||
console.debug("Websocket: ", URL);
|
console.debug("Websocket: ", URL);
|
||||||
|
|
||||||
export const socket = io(URL, {
|
export const socket = io(URL, {
|
||||||
path: `${forwardedPrefix}/ws/socket.io`,
|
path: `${forwardedPrefix}/ws/socket.io`,
|
||||||
transports: ["websocket"],
|
transports: ["websocket"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user