fixed duplicate v1 in url
This commit is contained in:
parent
13e2c18064
commit
7767110982
2 changed files with 2 additions and 27 deletions
|
|
@ -1,22 +1,10 @@
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import { useEffect, useRef, useCallback, useMemo } from "react";
|
import { useEffect, useRef, useCallback, useMemo } from "react";
|
||||||
|
import { getWsBaseUrl } from "utils/getWsBaseUrl";
|
||||||
|
|
||||||
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
||||||
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
||||||
|
|
||||||
/**
|
|
||||||
* Derives the WebSocket base URL from VITE_APP_API_URL.
|
|
||||||
* Matches the logic in useWebSocket.ts.
|
|
||||||
*/
|
|
||||||
function getWsBaseUrl(): string {
|
|
||||||
const apiUrl = import.meta.env.VITE_APP_API_URL;
|
|
||||||
if (apiUrl) {
|
|
||||||
return apiUrl.replace(/^http/, "ws");
|
|
||||||
}
|
|
||||||
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
||||||
return `${protocol}//${window.location.host}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UseDeviceStatusStreamsOptions {
|
export interface UseDeviceStatusStreamsOptions {
|
||||||
/** Device IDs to stream status for (e.g. from the visible devices list) */
|
/** Device IDs to stream status for (e.g. from the visible devices list) */
|
||||||
deviceIds: string[];
|
deviceIds: string[];
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
import { useEffect, useRef, useCallback } from "react";
|
import { useEffect, useRef, useCallback } from "react";
|
||||||
|
import { getWsBaseUrl } from "utils/getWsBaseUrl";
|
||||||
|
|
||||||
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
||||||
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
||||||
|
|
||||||
/**
|
|
||||||
* Derives the WebSocket base URL from VITE_APP_API_URL.
|
|
||||||
* e.g. "https://api.brandxtech.ca" -> "wss://api.brandxtech.ca"
|
|
||||||
* Falls back to current page host for local dev.
|
|
||||||
*/
|
|
||||||
function getWsBaseUrl(): string {
|
|
||||||
const apiUrl = import.meta.env.VITE_APP_API_URL;
|
|
||||||
if (apiUrl) {
|
|
||||||
return apiUrl.replace(/^http/, "ws");
|
|
||||||
}
|
|
||||||
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
||||||
return `${protocol}//${window.location.host}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UseWebSocketOptions<T> {
|
interface UseWebSocketOptions<T> {
|
||||||
/** The API path including /v1, e.g. "/v1/live/devices/123/components" */
|
/** The API path including /v1, e.g. "/v1/live/devices/123/components" */
|
||||||
path: string;
|
path: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue