feat: support sub route config (#3071)
* feat: support sub route config * dockerfile * fix upload * delete unused code
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { useSystemStore } from '../system/useSystemStore';
|
||||
import { formatTime2YMDHMW } from '@fastgpt/global/common/string/time';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
|
||||
type StreamFetchProps = {
|
||||
url?: string;
|
||||
@@ -136,7 +137,7 @@ export const streamFetch = ({
|
||||
};
|
||||
|
||||
// send request
|
||||
await fetchEventSource(url, {
|
||||
await fetchEventSource(getWebReqUrl(url), {
|
||||
...requestData,
|
||||
async onopen(res) {
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { clearToken } from '@/web/support/user/auth';
|
||||
import { TOKEN_ERROR_CODE } from '@fastgpt/global/common/error/errorCode';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { useSystemStore } from '../system/useSystemStore';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
|
||||
interface ConfigType {
|
||||
headers?: { [key: string]: string };
|
||||
@@ -114,7 +115,7 @@ function responseError(err: any) {
|
||||
!(window.location.pathname === '/chat/share' || window.location.pathname === '/chat/team')
|
||||
) {
|
||||
window.location.replace(
|
||||
`/login?lastRoute=${encodeURIComponent(location.pathname + location.search)}`
|
||||
getWebReqUrl(`/login?lastRoute=${encodeURIComponent(location.pathname + location.search)}`)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ function request(
|
||||
|
||||
return instance
|
||||
.request({
|
||||
baseURL: '/api',
|
||||
baseURL: getWebReqUrl('/api'),
|
||||
url,
|
||||
method,
|
||||
data: ['POST', 'PUT'].includes(method) ? data : null,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
export const getMd = async (url: string) => {
|
||||
const response = await fetch(`/docs/${url}`);
|
||||
const response = await fetch(getWebReqUrl(`/docs/${url}`));
|
||||
const textContent = await response.text();
|
||||
return textContent;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import { useSystemStore } from './useSystemStore';
|
||||
export const getDocPath = (path: string) => {
|
||||
const feConfigs = useSystemStore.getState().feConfigs;
|
||||
@@ -5,5 +6,6 @@ export const getDocPath = (path: string) => {
|
||||
if (!feConfigs?.docUrl) return '';
|
||||
if (!path.startsWith('/')) return path;
|
||||
if (feConfigs.docUrl.endsWith('/')) return feConfigs.docUrl.slice(0, -1);
|
||||
return feConfigs.docUrl + path;
|
||||
|
||||
return getWebReqUrl(feConfigs.docUrl + path);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import { TTSTypeEnum } from '@/web/core/app/constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat.d';
|
||||
import { useMount } from 'ahooks';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
|
||||
const contentType = 'audio/mpeg';
|
||||
const splitMarker = 'SPLIT_MARKER';
|
||||
@@ -45,7 +46,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
setAudioLoading(true);
|
||||
audioController.current = new AbortController();
|
||||
|
||||
const response = await fetch('/api/core/chat/item/getSpeech', {
|
||||
const response = await fetch(getWebReqUrl('/api/core/chat/item/getSpeech'), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user