Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions docs/self-hosting/environment-variables/basic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ When using the `random` mode, a random API Key will be selected from the availab

When using the `turn` mode, the API Keys will be retrieved in a polling manner according to the specified order.

### `NEXT_PUBLIC_BASE_PATH`

- Type: Optional
- Description: Add a `basePath` for LobeChat.
- Default: -
- Example: `/test`

### `DEFAULT_AGENT_CONFIG`

- Type: Optional
Expand Down
7 changes: 0 additions & 7 deletions docs/self-hosting/environment-variables/basic.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境

使用 `turn` 模式下,将按照填写的顺序,轮询获取得到 API Key。

### `NEXT_PUBLIC_BASE_PATH`

- 类型:可选
- 描述:为 LobeChat 添加 `basePath`
- 默认值: `-`
- 示例: `/test`

### `DEFAULT_AGENT_CONFIG`

- 类型:可选
Expand Down
2 changes: 0 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const shouldUseCSP = process.env.ENABLED_CSP === '1';

// if you need to proxy the api endpoint to remote server

const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
const isStandaloneMode = buildWithDocker || isDesktop;

const standaloneConfig: NextConfig = {
Expand All @@ -23,7 +22,6 @@ const standaloneConfig: NextConfig = {

const nextConfig: NextConfig = {
...(isStandaloneMode ? standaloneConfig : {}),
basePath,
compress: isProd,
experimental: {
optimizePackageImports: [
Expand Down
3 changes: 1 addition & 2 deletions packages/const/src/url.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import qs from 'query-string';
import urlJoin from 'url-join';

import { withBasePath } from '@/utils/basePath';
import { isDev } from '@/utils/env';

import { INBOX_SESSION_ID } from './session';
Expand Down Expand Up @@ -56,7 +55,7 @@ export const SESSION_CHAT_URL = (id: string = INBOX_SESSION_ID, mobile?: boolean
url: '/chat',
});

export const imageUrl = (filename: string) => withBasePath(`/images/${filename}`);
export const imageUrl = (filename: string) => `/images/${filename}`;

export const LOBE_URL_IMPORT_NAME = 'settings';

Expand Down
3 changes: 0 additions & 3 deletions packages/utils/src/basePath.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/libs/trpc/client/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import superjson from 'superjson';

import { isDesktop } from '@/const/version';
import type { EdgeRouter } from '@/server/routers/edge';
import { withBasePath } from '@/utils/basePath';
import { fetchWithDesktopRemoteRPC } from '@/utils/electron/desktopRemoteRPCFetch';

export const edgeClient = createTRPCClient<EdgeRouter>({
Expand All @@ -21,7 +20,7 @@ export const edgeClient = createTRPCClient<EdgeRouter>({
},
maxURLLength: 2083,
transformer: superjson,
url: withBasePath('/trpc/edge'),
url: '/trpc/edge',
}),
],
});
25 changes: 6 additions & 19 deletions src/services/_url.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { transform } from 'lodash-es';

import { withBasePath } from '@/utils/basePath';

const mapWithBasePath = <T extends object>(apis: T): T => {
return transform(apis, (result, value, key) => {
if (typeof value === 'string') {
// @ts-ignore
result[key] = withBasePath(value);
} else {
result[key] = value;
}
});
};

export const API_ENDPOINTS = mapWithBasePath({

export const API_ENDPOINTS = {
oauth: '/api/auth',

proxy: '/webapi/proxy',
Expand All @@ -26,11 +13,11 @@ export const API_ENDPOINTS = mapWithBasePath({
trace: '/webapi/trace',

// chat
chat: (provider: string) => withBasePath(`/webapi/chat/${provider}`),
chat: (provider: string) => `/webapi/chat/${provider}`,

// models
models: (provider: string) => withBasePath(`/webapi/models/${provider}`),
modelPull: (provider: string) => withBasePath(`/webapi/models/${provider}/pull`),
models: (provider: string) => `/webapi/models/${provider}`,
modelPull: (provider: string) => `/webapi/models/${provider}/pull`,

// image
images: (provider: string) => `/webapi/text-to-image/${provider}`,
Expand All @@ -42,4 +29,4 @@ export const API_ENDPOINTS = mapWithBasePath({
tts: '/webapi/tts/openai',
edge: '/webapi/tts/edge',
microsoft: '/webapi/tts/microsoft',
});
};
3 changes: 1 addition & 2 deletions src/services/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { PartialDeep } from 'type-fest';

import { LOBE_URL_IMPORT_NAME } from '@/const/url';
import { UserSettings } from '@/types/user/settings';
import { withBasePath } from '@/utils/basePath';

class ShareService {
/**
Expand All @@ -11,7 +10,7 @@ class ShareService {
* @returns The share settings URL.
*/
public createShareSettingsUrl = (settings: PartialDeep<UserSettings>) => {
return withBasePath(`/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`);
return `/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`;
};

/**
Expand Down