diff --git a/.env.development b/.env.development index 81b3be797..cbab83245 100644 --- a/.env.development +++ b/.env.development @@ -1,8 +1,18 @@ VITE_BASE_URL=/api +# =======Production environment variables======= +SERVER_URL=https://dev.eigent.ai VITE_PROXY_URL=https://dev.eigent.ai +VITE_SITE_URL=https://www.eigent.ai VITE_USE_LOCAL_PROXY=false +# =======Test environment variables======= +# SERVER_URL=https://test-dev.eigent.ai +# VITE_PROXY_URL=https://test-dev.eigent.ai +# VITE_SITE_URL=https://test.eigent.ai +# VITE_USE_LOCAL_PROXY=false + +# =======Local environment variables======= # VITE_PROXY_URL=http://localhost:3001 # VITE_USE_LOCAL_PROXY=true diff --git a/electron/main/init.ts b/electron/main/init.ts index 57fb26c87..b7b3c62e7 100644 --- a/electron/main/init.ts +++ b/electron/main/init.ts @@ -289,6 +289,16 @@ export async function startBackend( } } + // In dev mode, also check .env.development for SERVER_URL + if (!resolvedServerUrl && devServerUrl) { + const devEnvPath = path.join(app.getAppPath(), '.env.development'); + const devFileServerUrl = readEnvValue(devEnvPath, 'SERVER_URL'); + if (devFileServerUrl) { + resolvedServerUrl = devFileServerUrl; + resolvedSource = `dev env file SERVER_URL (${devEnvPath})`; + } + } + if (!resolvedServerUrl && process.env.SERVER_URL) { resolvedServerUrl = process.env.SERVER_URL; resolvedSource = 'process.env SERVER_URL'; diff --git a/src/components/Toast/creditsToast.tsx b/src/components/Toast/creditsToast.tsx index 9c5f2319a..c0846ebb2 100644 --- a/src/components/Toast/creditsToast.tsx +++ b/src/components/Toast/creditsToast.tsx @@ -13,6 +13,7 @@ // ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= import i18n from '@/i18n'; +import { SITE_URL } from '@/lib'; import { toast } from 'sonner'; export function showCreditsToast() { @@ -22,7 +23,7 @@ export function showCreditsToast() { {i18n.t('chat.you-ve-reached-the-limit-of-your-current-plan')} (window.location.href = 'https://www.eigent.ai/pricing')} + onClick={() => (window.location.href = `${SITE_URL}/pricing`)} > {i18n.t('chat.upgrade')} {' '} diff --git a/src/components/Toast/storageToast.tsx b/src/components/Toast/storageToast.tsx index e10639a0c..5c3fbd98e 100644 --- a/src/components/Toast/storageToast.tsx +++ b/src/components/Toast/storageToast.tsx @@ -13,6 +13,7 @@ // ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= import i18n from '@/i18n'; +import { SITE_URL } from '@/lib'; import { toast } from 'sonner'; export function showStorageToast() { @@ -25,7 +26,7 @@ export function showStorageToast() { Please{' '} (window.location.href = 'https://www.eigent.ai/pricing')} + onClick={() => (window.location.href = `${SITE_URL}/pricing`)} > {i18n.t('chat.upgrade')} {' '} diff --git a/src/components/TopBar/index.tsx b/src/components/TopBar/index.tsx index 1dc18956b..18ea1fa92 100644 --- a/src/components/TopBar/index.tsx +++ b/src/components/TopBar/index.tsx @@ -25,6 +25,7 @@ import EndNoticeDialog from '@/components/Dialog/EndNotice'; import { Button } from '@/components/ui/button'; import { TooltipSimple } from '@/components/ui/tooltip'; import useChatStoreAdapter from '@/hooks/useChatStoreAdapter'; +import { SITE_URL } from '@/lib'; import { share } from '@/lib/share'; import { useAuthStore } from '@/store/authStore'; import { useInstallationUI } from '@/store/installationStore'; @@ -113,7 +114,7 @@ function HeaderWin() { try { const res: any = await proxyFetchGet('/api/v1/user/invite_code'); if (res?.invite_code) { - const inviteLink = `https://www.eigent.ai/signup?invite_code=${res.invite_code}`; + const inviteLink = `${SITE_URL}/signup?invite_code=${res.invite_code}`; await navigator.clipboard.writeText(inviteLink); toast.success(t('layout.invitation-link-copied')); } else { diff --git a/src/lib/index.ts b/src/lib/index.ts index 55ea93e08..63fbcf8a1 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -14,6 +14,9 @@ import { getAuthStore } from '@/store/authStore'; +export const SITE_URL = + import.meta.env.VITE_SITE_URL || 'https://www.eigent.ai'; + export function getProxyBaseURL() { const isDev = import.meta.env.DEV; diff --git a/src/lib/share.ts b/src/lib/share.ts index 2754e04ba..e0000af50 100644 --- a/src/lib/share.ts +++ b/src/lib/share.ts @@ -13,6 +13,7 @@ // ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= import { proxyFetchPost } from '@/api/http'; +import { SITE_URL } from '@/lib'; import { toast } from 'sonner'; export const share = async (taskId: string) => { @@ -20,7 +21,7 @@ export const share = async (taskId: string) => { const res = await proxyFetchPost(`/api/v1/chat/share`, { task_id: taskId, }); - const shareLink = `${import.meta.env.VITE_USE_LOCAL_PROXY === 'true' ? 'eigent://callback' : 'https://www.eigent.ai/download'}?share_token=${res.share_token}__${taskId}`; + const shareLink = `${import.meta.env.VITE_USE_LOCAL_PROXY === 'true' ? 'eigent://callback' : `${SITE_URL}/download`}?share_token=${res.share_token}__${taskId}`; navigator.clipboard .writeText(shareLink) .then(() => { diff --git a/src/pages/Agents/Models.tsx b/src/pages/Agents/Models.tsx index 8e2c12859..ab1372ca0 100644 --- a/src/pages/Agents/Models.tsx +++ b/src/pages/Agents/Models.tsx @@ -37,6 +37,7 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select'; +import { SITE_URL } from '@/lib'; import { INIT_PROVODERS } from '@/lib/llm'; import { useAuthStore } from '@/store/authStore'; import { Provider } from '@/types'; @@ -1202,7 +1203,7 @@ export default function SettingModels() { { - window.location.href = `https://www.eigent.ai/pricing`; + window.location.href = `${SITE_URL}/pricing`; }} className="cursor-pointer text-body-sm text-text-label underline" > @@ -1225,7 +1226,7 @@ export default function SettingModels() {