-
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 0a828816..ea0ed0f1 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -229,13 +229,16 @@
"checkUpdates": "Check for Updates",
"checkingUpdates": "Checking for updates...",
"refresh": "Refresh",
- "updateRequired": "Update Required"
+ "updateRequired": "Update Required",
+ "updateDismissed": "Update notification dismissed",
+ "noUpdatesFound": "No updates found"
},
"common": {
"close": "Close",
"minimize": "Minimize",
"online": "Online",
"offline": "Offline",
+ "continue": "Continue",
"maintenance": "Maintenance",
"degraded": "Degraded",
"discord": "Discord",
diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json
index e090991b..3c03045e 100644
--- a/src/locales/zh/translation.json
+++ b/src/locales/zh/translation.json
@@ -227,13 +227,16 @@
"checkUpdates": "检查更新",
"checkingUpdates": "正在检查更新...",
"refresh": "刷新",
- "updateRequired": "需要更新"
+ "updateRequired": "需要更新",
+ "updateDismissed": "更新通知已忽略",
+ "noUpdatesFound": "未找到更新"
},
"common": {
"close": "关闭",
"minimize": "最小化",
"online": "在线",
"offline": "离线",
+ "continue": "继续",
"maintenance": "维护中",
"degraded": "降级",
"discord": "Discord",
diff --git a/src/ui/Desktop/Admin/AdminSettings.tsx b/src/ui/Desktop/Admin/AdminSettings.tsx
index 25cfa568..1fad2851 100644
--- a/src/ui/Desktop/Admin/AdminSettings.tsx
+++ b/src/ui/Desktop/Admin/AdminSettings.tsx
@@ -273,7 +273,7 @@ export function AdminSettings({
try {
const apiUrl = isElectron()
? `${(window as any).configuredServerUrl}/database/export`
- : "http://localhost:30001/database/export";
+ : "/database/export";
const response = await fetch(apiUrl, {
method: "POST",
@@ -333,7 +333,7 @@ export function AdminSettings({
try {
const apiUrl = isElectron()
? `${(window as any).configuredServerUrl}/database/import`
- : "http://localhost:30001/database/import";
+ : "/database/import";
const formData = new FormData();
formData.append("file", importFile);
diff --git a/src/ui/Desktop/DesktopApp.tsx b/src/ui/Desktop/DesktopApp.tsx
index 2e21f0cc..6af4f825 100644
--- a/src/ui/Desktop/DesktopApp.tsx
+++ b/src/ui/Desktop/DesktopApp.tsx
@@ -100,10 +100,11 @@ function AppContent() {
setShowVersionCheck(false)}
onContinue={() => setShowVersionCheck(false)}
+ isAuthenticated={isAuthenticated}
/>
)}
- {!isAuthenticated && !authLoading && (
+ {!isAuthenticated && !authLoading && !showVersionCheck && (
)}
- {!isAuthenticated && !authLoading && (
+ {!isAuthenticated && !authLoading && !showVersionCheck && (
)}
- {!internalLoggedIn && !authLoading && !totpRequired && (
+ {!loggedIn && !authLoading && !totpRequired && (
<>
@@ -974,7 +974,7 @@ export function HomepageAuth({
className="h-11 text-base"
value={password}
onChange={(e) => setPassword(e.target.value)}
- disabled={loading || internalLoggedIn}
+ disabled={loading || loggedIn}
/>
{tab === "signup" && (
@@ -988,7 +988,7 @@ export function HomepageAuth({
className="h-11 text-base"
value={signupConfirmPassword}
onChange={(e) => setSignupConfirmPassword(e.target.value)}
- disabled={loading || internalLoggedIn}
+ disabled={loading || loggedIn}
/>
)}
@@ -1008,7 +1008,7 @@ export function HomepageAuth({
type="button"
variant="outline"
className="w-full h-11 text-base font-semibold"
- disabled={loading || internalLoggedIn}
+ disabled={loading || loggedIn}
onClick={() => {
setTab("reset");
resetPasswordState();
diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts
index d7446f09..e1cecf98 100644
--- a/src/ui/main-axios.ts
+++ b/src/ui/main-axios.ts
@@ -142,7 +142,7 @@ function createApiInstance(
baseURL,
headers: { "Content-Type": "application/json" },
timeout: 30000,
- withCredentials: true, // Required for HttpOnly cookies to be sent cross-origin
+ withCredentials: true,
});
instance.interceptors.request.use((config) => {
@@ -168,13 +168,14 @@ function createApiInstance(
if (process.env.NODE_ENV === "development") {
logger.requestStart(method, fullUrl, context);
}
-
- // Note: JWT token is now automatically sent via secure HttpOnly cookies
- // No need to manually set Authorization header for cookie-based auth
-
+
if (isElectron()) {
config.headers["X-Electron-App"] = "true";
- config.headers["User-Agent"] = "Termix-Electron/1.6.0";
+
+ const token = localStorage.getItem("jwt");
+ if (token) {
+ config.headers["Authorization"] = `Bearer ${token}`;
+ }
}
return config;
@@ -300,6 +301,10 @@ function createApiInstance(
// ============================================================================
function isDev(): boolean {
+ if (isElectron()) {
+ return false;
+ }
+
return (
process.env.NODE_ENV === "development" &&
(window.location.port === "3000" ||
@@ -347,6 +352,7 @@ export async function saveServerConfig(config: ServerConfig): Promise
{
);
if (result?.success) {
configuredServerUrl = config.serverUrl;
+ (window as any).configuredServerUrl = configuredServerUrl;
updateApiInstances();
return true;
}
@@ -405,18 +411,8 @@ export async function checkElectronUpdate(): Promise<{
}
}
-if (isElectron()) {
- getServerConfig().then((config) => {
- if (config?.serverUrl) {
- configuredServerUrl = config.serverUrl;
- updateApiInstances();
- }
- });
-}
-
function getApiUrl(path: string, defaultPort: number): string {
if (isDev()) {
- // Auto-detect HTTPS in development
const protocol = window.location.protocol === "https:" ? "https" : "http";
const sslPort = protocol === "https" ? 8443 : defaultPort;
return `${protocol}://${apiHost}:${sslPort}${path}`;
@@ -466,7 +462,20 @@ export let statsApi: AxiosInstance;
// Authentication API (port 30001)
export let authApi: AxiosInstance;
-initializeApiInstances();
+if (isElectron()) {
+ getServerConfig().then((config) => {
+ if (config?.serverUrl) {
+ configuredServerUrl = config.serverUrl;
+ (window as any).configuredServerUrl = configuredServerUrl;
+ }
+ initializeApiInstances();
+ }).catch((error) => {
+ console.error("Failed to load server config, initializing with default:", error);
+ initializeApiInstances();
+ });
+} else {
+ initializeApiInstances();
+}
function updateApiInstances() {
systemLogger.info("Updating API instances with new server configuration", {
@@ -1518,8 +1527,13 @@ export async function loginUser(
): Promise {
try {
const response = await authApi.post("/users/login", { username, password });
+
+ if (isElectron() && response.data.token) {
+ localStorage.setItem("jwt", response.data.token);
+ }
+
return {
- token: "cookie-based",
+ token: response.data.token || "cookie-based",
success: response.data.success,
is_admin: response.data.is_admin,
username: response.data.username,