diff --git a/src/ui/Desktop/Navigation/LeftSidebar.tsx b/src/ui/Desktop/Navigation/LeftSidebar.tsx
index e2419014..cc7f1b31 100644
--- a/src/ui/Desktop/Navigation/LeftSidebar.tsx
+++ b/src/ui/Desktop/Navigation/LeftSidebar.tsx
@@ -3,7 +3,7 @@ import {
ChevronUp, User2, HardDrive, Menu, ChevronRight
} from "lucide-react";
import { useTranslation } from 'react-i18next';
-import {getCookie, setCookie} from "@/ui/main-axios.ts";
+import {getCookie, setCookie, isElectron} from "@/ui/main-axios.ts";
import {
Sidebar,
@@ -61,10 +61,6 @@ interface SidebarProps {
children?: React.ReactNode;
}
-function isElectron() {
- const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
- return isElectron;
-}
function handleLogout() {
if (isElectron()) {
diff --git a/src/ui/Mobile/Apps/Terminal/Terminal.tsx b/src/ui/Mobile/Apps/Terminal/Terminal.tsx
index efe1d23e..bfc21e9e 100644
--- a/src/ui/Mobile/Apps/Terminal/Terminal.tsx
+++ b/src/ui/Mobile/Apps/Terminal/Terminal.tsx
@@ -5,6 +5,7 @@ import {ClipboardAddon} from '@xterm/addon-clipboard';
import {Unicode11Addon} from '@xterm/addon-unicode11';
import {WebLinksAddon} from '@xterm/addon-web-links';
import {useTranslation} from 'react-i18next';
+import {isElectron} from '@/ui/main-axios.ts';
interface SSHTerminalProps {
hostConfig: any;
@@ -215,11 +216,10 @@ export const Terminal = forwardRef
(function SSHTerminal(
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
- const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const wsUrl = isDev
? 'ws://localhost:8082'
- : isElectron
+ : isElectron()
? (() => {
// Get configured server URL from window object (set by main-axios)
const baseUrl = (window as any).configuredServerUrl || 'http://127.0.0.1:8081';
diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts
index 0b0adecd..cdbeb18c 100644
--- a/src/ui/main-axios.ts
+++ b/src/ui/main-axios.ts
@@ -75,6 +75,10 @@ interface OIDCAuthorize {
// UTILITY FUNCTIONS
// ============================================================================
+export function isElectron(): boolean {
+ return (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
+}
+
function getLoggerForService(serviceName: string) {
if (serviceName.includes('SSH') || serviceName.includes('ssh')) {
return sshLogger;
@@ -92,9 +96,7 @@ function getLoggerForService(serviceName: string) {
}
export function setCookie(name: string, value: string, days = 7): void {
- const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
-
- if (isElectron) {
+ if (isElectron()) {
localStorage.setItem(name, value);
} else {
const expires = new Date(Date.now() + days * 864e5).toUTCString();
@@ -103,8 +105,7 @@ export function setCookie(name: string, value: string, days = 7): void {
}
export function getCookie(name: string): string | undefined {
- const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
- if (isElectron) {
+ if (isElectron()) {
const token = localStorage.getItem(name) || undefined;
return token;
} else {
@@ -243,8 +244,7 @@ function createApiInstance(baseURL: string, serviceName: string = 'API'): AxiosI
// Handle auth token clearing
if (status === 401) {
- const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
- if (isElectron) {
+ if (isElectron()) {
localStorage.removeItem('jwt');
} else {
document.cookie = 'jwt=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
@@ -263,7 +263,6 @@ function createApiInstance(baseURL: string, serviceName: string = 'API'): AxiosI
// API INSTANCES
// ============================================================================
-const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
@@ -334,7 +333,7 @@ if (isElectron) {
}
function getApiUrl(path: string, defaultPort: number): string {
- if (isElectron) {
+ if (isElectron()) {
if (configuredServerUrl) {
// In Electron with configured server, all requests go through nginx reverse proxy
// Use the same base URL for all services (nginx routes to correct backend port)