mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
Commercial baseurl (#697)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axios, { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { FastGPTProUrl } from '../system/constants';
|
||||
|
||||
interface ConfigType {
|
||||
headers?: { [key: string]: string };
|
||||
@@ -70,7 +71,7 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
|
||||
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
|
||||
|
||||
export function request(url: string, data: any, config: ConfigType, method: Method): any {
|
||||
if (!global.systemEnv || !global.systemEnv?.pluginBaseUrl) {
|
||||
if (!FastGPTProUrl) {
|
||||
console.log('未部署商业版接口', url);
|
||||
return Promise.reject('The The request was denied...');
|
||||
}
|
||||
@@ -84,7 +85,7 @@ export function request(url: string, data: any, config: ConfigType, method: Meth
|
||||
|
||||
return instance
|
||||
.request({
|
||||
baseURL: global.systemEnv.pluginBaseUrl,
|
||||
baseURL: FastGPTProUrl,
|
||||
url,
|
||||
method,
|
||||
data: ['POST', 'PUT'].includes(method) ? data : null,
|
||||
|
@@ -21,9 +21,6 @@ export const htmlToMarkdown = (html?: string | null) =>
|
||||
worker.terminate();
|
||||
reject(err);
|
||||
});
|
||||
worker.on('exit', (code) => {
|
||||
console.log('html 2 md finish', code);
|
||||
});
|
||||
|
||||
worker.postMessage(html);
|
||||
});
|
||||
|
@@ -1,8 +1,11 @@
|
||||
import { SystemConfigsTypeEnum } from '@fastgpt/global/common/system/config/constants';
|
||||
import { MongoSystemConfigs } from './schema';
|
||||
import { FastGPTConfigFileType } from '@fastgpt/global/common/system/types';
|
||||
import { FastGPTProUrl } from '../constants';
|
||||
|
||||
export const getFastGPTConfigFromDB = async () => {
|
||||
if (!FastGPTProUrl) return {} as FastGPTConfigFileType;
|
||||
|
||||
const res = await MongoSystemConfigs.findOne({
|
||||
type: SystemConfigsTypeEnum.fastgpt
|
||||
}).sort({
|
||||
@@ -11,5 +14,5 @@ export const getFastGPTConfigFromDB = async () => {
|
||||
|
||||
const config = res?.value || {};
|
||||
|
||||
return config as Omit<FastGPTConfigFileType, 'systemEnv'>;
|
||||
return config as FastGPTConfigFileType;
|
||||
};
|
||||
|
1
packages/service/common/system/constants.ts
Normal file
1
packages/service/common/system/constants.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const FastGPTProUrl = process.env.PRO_URL ? `${process.env.PRO_URL}/api` : '';
|
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import { MongoOutLink } from './schema';
|
||||
import { FastGPTProUrl } from '../../common/system/constants';
|
||||
|
||||
export const updateOutLinkUsage = async ({
|
||||
shareId,
|
||||
@@ -30,7 +31,7 @@ export const pushResult2Remote = async ({
|
||||
shareId?: string;
|
||||
responseData?: any[];
|
||||
}) => {
|
||||
if (!shareId || !outLinkUid || !global.systemEnv?.pluginBaseUrl) return;
|
||||
if (!shareId || !outLinkUid || !FastGPTProUrl) return;
|
||||
try {
|
||||
const outLink = await MongoOutLink.findOne({
|
||||
shareId
|
||||
|
Reference in New Issue
Block a user