From fa6e75012b7cf69d986ba9425113b8cbef38c816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E4=BA=91=E7=99=BD=E5=9C=9F?= Date: Tue, 28 May 2024 15:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Fixed=20jump=20error=20wh?= =?UTF-8?q?en=20requesting=20desktop=20website?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/const/url.ts | 16 +++++++++++++++- src/libs/agent-runtime/openrouter/index.ts | 2 +- src/libs/agent-runtime/togetherai/index.ts | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/const/url.ts b/src/const/url.ts index dc9d603edf74..1c8aeb4585ce 100644 --- a/src/const/url.ts +++ b/src/const/url.ts @@ -6,7 +6,21 @@ import { withBasePath } from '@/utils/basePath'; import pkg from '../../package.json'; import { INBOX_SESSION_ID } from './session'; -export const OFFICIAL_URL = 'https://chat-preview.lobehub.com/'; +const isVercelPreview = process.env.VERCEL === '1' && process.env.VERCEL_ENV !== 'production'; + +const inVercelProduction = process.env.VERCEL === '1' && process.env.VERCEL_ENV === 'production'; + +const vercelPreviewUrl = `https://${process.env.VERCEL_URL}`; + +const vercelProductionUrl = `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`; + +export const siteUrl = inVercelProduction + ? vercelProductionUrl + : isVercelPreview + ? vercelPreviewUrl + : 'https://chat-preview.lobehub.com'; + +export const OFFICIAL_URL = siteUrl; export const OFFICIAL_SITE = 'https://lobehub.com/'; export const getCanonicalUrl = (path: string) => urlJoin(OFFICIAL_URL, path); diff --git a/src/libs/agent-runtime/openrouter/index.ts b/src/libs/agent-runtime/openrouter/index.ts index d891b608d033..0995593c4fc8 100644 --- a/src/libs/agent-runtime/openrouter/index.ts +++ b/src/libs/agent-runtime/openrouter/index.ts @@ -9,7 +9,7 @@ export const LobeOpenRouterAI = LobeOpenAICompatibleFactory({ baseURL: 'https://openrouter.ai/api/v1', constructorOptions: { defaultHeaders: { - 'HTTP-Referer': 'https://chat-preview.lobehub.com', + 'HTTP-Referer': 'siteUrl', 'X-Title': 'Lobe Chat', }, }, diff --git a/src/libs/agent-runtime/togetherai/index.ts b/src/libs/agent-runtime/togetherai/index.ts index 4904f0197bc8..011110b47cc2 100644 --- a/src/libs/agent-runtime/togetherai/index.ts +++ b/src/libs/agent-runtime/togetherai/index.ts @@ -10,7 +10,7 @@ export const LobeTogetherAI = LobeOpenAICompatibleFactory({ baseURL: `${baseURL}/v1`, constructorOptions: { defaultHeaders: { - 'HTTP-Referer': 'https://chat-preview.lobehub.com', + 'HTTP-Referer': 'siteUrl', 'X-Title': 'Lobe Chat', }, },