diff --git a/ui/src/components/TrafficPage.tsx b/ui/src/components/TrafficPage.tsx index 334003555..0983ad27c 100644 --- a/ui/src/components/TrafficPage.tsx +++ b/ui/src/components/TrafficPage.tsx @@ -211,7 +211,7 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS const entryData = await api.getEntry(focusedEntryId); setSelectedEntryData(entryData); } catch (error) { - if (error.response) { + if (error.response?.data?.type) { toast[error.response.data.type](`Entry[${focusedEntryId}]: ${error.response.data.msg}`, { position: "bottom-right", theme: "colored", diff --git a/ui/src/helpers/api.js b/ui/src/helpers/api.js index ef7404996..524b58334 100644 --- a/ui/src/helpers/api.js +++ b/ui/src/helpers/api.js @@ -1,7 +1,8 @@ import * as axios from "axios"; // When working locally cp `cp .env.example .env` -export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : `ws://${window.location.host}/ws`; +export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : + window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`; const CancelToken = axios.CancelToken;