Use a util function to wrap the add base path logic.
This commit is contained in:
parent
c39a93a512
commit
473dad2d16
@ -38,12 +38,8 @@ NEXT_PUBLIC_TOP_K_MAX_VALUE=10
|
||||
# The maximum number of tokens for segmentation
|
||||
NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=4000
|
||||
|
||||
# Set the value of basePath
|
||||
# example: /dify
|
||||
NEXT_PUBLIC_BASE_PATH=''
|
||||
|
||||
# Maximum loop count in the workflow
|
||||
NEXT_PUBLIC_LOOP_NODE_MAX_COUNT=100
|
||||
|
||||
# Maximum number of tools in the agent/workflow
|
||||
NEXT_PUBLIC_MAX_TOOLS_NUM=10
|
||||
NEXT_PUBLIC_MAX_TOOLS_NUM=10
|
||||
|
@ -29,8 +29,6 @@ FROM base AS builder
|
||||
WORKDIR /app/web
|
||||
COPY --from=packages /app/web/ .
|
||||
COPY . .
|
||||
# Set environment variables, at build time
|
||||
ENV NEXT_PUBLIC_BASE_PATH=
|
||||
|
||||
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||
RUN pnpm build
|
||||
@ -38,8 +36,6 @@ RUN pnpm build
|
||||
|
||||
# production stage
|
||||
FROM base AS production
|
||||
# Set environment variables, at run time
|
||||
ENV NEXT_PUBLIC_BASE_PATH=
|
||||
ENV NODE_ENV=production
|
||||
ENV EDITION=SELF_HOSTED
|
||||
ENV DEPLOY_ENV=PRODUCTION
|
||||
|
@ -18,6 +18,7 @@ import AppsContext, { useAppContext } from '@/context/app-context'
|
||||
import type { HtmlContentProps } from '@/app/components/base/popover'
|
||||
import CustomPopover from '@/app/components/base/popover'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
||||
@ -217,7 +218,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
|
||||
try {
|
||||
const { installed_apps }: any = await fetchInstalledAppList(app.id) || {}
|
||||
if (installed_apps?.length > 0)
|
||||
window.open(`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/explore/installed/${installed_apps[0].id}`, '_blank')
|
||||
window.open(`${basePath}/explore/installed/${installed_apps[0].id}`, '_blank')
|
||||
else
|
||||
throw new Error('No app found in Explore')
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import { forwardRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { basePath } from '@/utils/var'
|
||||
import {
|
||||
RiAddLine,
|
||||
RiArrowRightLine,
|
||||
@ -14,7 +15,7 @@ const CreateAppCard = forwardRef<HTMLAnchorElement>((_, ref) => {
|
||||
<div className='flex flex-col bg-background-default-dimm border-[0.5px] border-components-panel-border rounded-xl
|
||||
min-h-[160px] transition-all duration-200 ease-in-out'
|
||||
>
|
||||
<a ref={ref} className='group flex flex-grow items-start p-4 cursor-pointer' href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/datasets/create`}>
|
||||
<a ref={ref} className='group flex flex-grow items-start p-4 cursor-pointer' href={`${basePath}/datasets/create`}>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='w-10 h-10 p-2 flex items-center justify-center border border-dashed border-divider-regular rounded-lg
|
||||
bg-background-default-lighter group-hover:border-solid group-hover:border-effects-highlight group-hover:bg-background-default-dodge'
|
||||
@ -25,7 +26,7 @@ const CreateAppCard = forwardRef<HTMLAnchorElement>((_, ref) => {
|
||||
</div>
|
||||
</a>
|
||||
<div className='p-4 pt-0 text-text-tertiary system-xs-regular'>{t('dataset.createDatasetIntro')}</div>
|
||||
<a className='group flex p-4 items-center gap-1 border-t-[0.5px] border-divider-subtle rounded-b-xl cursor-pointer' href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/datasets/connect`}>
|
||||
<a className='group flex p-4 items-center gap-1 border-t-[0.5px] border-divider-subtle rounded-b-xl cursor-pointer' href={`${basePath}/datasets/connect`}>
|
||||
<div className='system-xs-medium text-text-tertiary group-hover:text-text-accent'>{t('dataset.connectDataset')}</div>
|
||||
<RiArrowRightLine className='w-3.5 h-3.5 text-text-tertiary group-hover:text-text-accent' />
|
||||
</a>
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
PortalToFollowElemContent,
|
||||
PortalToFollowElemTrigger,
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { fetchInstalledAppList } from '@/service/explore'
|
||||
import EmbeddedModal from '@/app/components/app/overview/embedded'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
@ -120,7 +121,7 @@ const AppPublisher = ({
|
||||
try {
|
||||
const { installed_apps }: any = await fetchInstalledAppList(appDetail?.id) || {}
|
||||
if (installed_apps?.length > 0)
|
||||
window.open(`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/explore/installed/${installed_apps[0].id}`, '_blank')
|
||||
window.open(`${basePath}/explore/installed/${installed_apps[0].id}`, '_blank')
|
||||
else
|
||||
throw new Error('No app found in Explore')
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import { usePathname } from 'next/navigation'
|
||||
@ -504,7 +505,6 @@ const Configuration: FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
const collectionList = await fetchCollectionList()
|
||||
if (basePath) {
|
||||
collectionList.forEach((item) => {
|
||||
|
@ -14,6 +14,7 @@ import type { AppIconSelection } from '../../base/app-icon-picker'
|
||||
import Button from '@/app/components/base/button'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import AppsContext, { useAppContext } from '@/context/app-context'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
@ -34,7 +35,6 @@ type CreateAppProps = {
|
||||
onClose: () => void
|
||||
onCreateFromTemplate?: () => void
|
||||
}
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
function CreateApp({ onClose, onSuccess, onCreateFromTemplate }: CreateAppProps) {
|
||||
const { t } = useTranslation()
|
||||
const { push } = useRouter()
|
||||
|
@ -7,6 +7,7 @@ import { usePathname } from 'next/navigation'
|
||||
import { useDebounce } from 'ahooks'
|
||||
import { omit } from 'lodash-es'
|
||||
import dayjs from 'dayjs'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import List from './list'
|
||||
import Filter, { TIME_PERIOD_MAPPING } from './filter'
|
||||
@ -99,7 +100,6 @@ const Logs: FC<ILogsProps> = ({ appDetail }) => {
|
||||
: null, fetchCompletionConversations)
|
||||
|
||||
const total = isChatMode ? chatConversations?.total : completionConversations?.total
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
return (
|
||||
<div className='grow flex flex-col h-full'>
|
||||
<p className='shrink-0 text-text-tertiary system-sm-regular'>{t('appLog.description')}</p>
|
||||
|
@ -17,6 +17,7 @@ import type { ConfigParams } from './settings'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import AppBasic from '@/app/components/app-sidebar/basic'
|
||||
import { asyncRunSafe, randomString } from '@/utils'
|
||||
import { basePath } from '@/utils/var'
|
||||
import Button from '@/app/components/base/button'
|
||||
import Switch from '@/app/components/base/switch'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
@ -88,7 +89,7 @@ function AppCard({
|
||||
const runningStatus = isApp ? appInfo.enable_site : appInfo.enable_api
|
||||
const { app_base_url, access_token } = appInfo.site ?? {}
|
||||
const appMode = (appInfo.mode !== 'completion' && appInfo.mode !== 'workflow') ? 'chat' : appInfo.mode
|
||||
const appUrl = `${app_base_url}${process.env.NEXT_PUBLIC_BASE_PATH || ''}/${appMode}/${access_token}`
|
||||
const appUrl = `${app_base_url}${basePath}/${appMode}/${access_token}`
|
||||
const apiUrl = appInfo?.api_base_url
|
||||
|
||||
const genClickFuncByName = (opName: string) => {
|
||||
|
@ -13,6 +13,7 @@ import { IS_CE_EDITION } from '@/config'
|
||||
import type { SiteInfo } from '@/models/share'
|
||||
import { useThemeContext } from '@/app/components/base/chat/embedded-chatbot/theme/theme-context'
|
||||
import ActionButton from '@/app/components/base/action-button'
|
||||
import { basePath } from '@/utils/var'
|
||||
import cn from '@/utils/classnames'
|
||||
|
||||
type Props = {
|
||||
@ -23,7 +24,6 @@ type Props = {
|
||||
appBaseUrl: string
|
||||
className?: string
|
||||
}
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
const OPTION_MAP = {
|
||||
iframe: {
|
||||
getContent: (url: string, token: string) =>
|
||||
|
@ -11,6 +11,7 @@ import timezone from 'dayjs/plugin/timezone'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import Link from 'next/link'
|
||||
import List from './list'
|
||||
import { basePath } from '@/utils/var'
|
||||
import Filter, { TIME_PERIOD_MAPPING } from './filter'
|
||||
import Pagination from '@/app/components/base/pagination'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
@ -32,7 +33,6 @@ export type QueryParam = {
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
const ThreeDotsIcon = ({ className }: SVGProps<SVGElement>) => {
|
||||
return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>
|
||||
<path d="M5 6.5V5M8.93934 7.56066L10 6.5M10.0103 11.5H11.5103" stroke="#374151" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
import { basePath } from '@/utils/var'
|
||||
|
||||
type LogoEmbeddedChatHeaderProps = {
|
||||
className?: string
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import { basePath } from '@/utils/var'
|
||||
import classNames from '@/utils/classnames'
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
|
||||
type LogoSiteProps = {
|
||||
className?: string
|
||||
|
@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { Menu, Transition } from '@headlessui/react'
|
||||
import { RiArrowDownSLine } from '@remixicon/react'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { switchWorkspace } from '@/service/common'
|
||||
import { useWorkspacesContext } from '@/context/workspace-context'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
@ -22,7 +23,7 @@ const WorkplaceSelector = () => {
|
||||
return
|
||||
await switchWorkspace({ url: '/workspaces/switch', body: { tenant_id } })
|
||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||
location.assign(`${location.origin}${process.env.NEXT_PUBLIC_BASE_PATH || ''}`)
|
||||
location.assign(`${location.origin}${basePath}`)
|
||||
}
|
||||
catch (e) {
|
||||
notify({ type: 'error', message: t('common.provider.saveFailed') })
|
||||
|
@ -5,13 +5,13 @@ import copy from 'copy-to-clipboard'
|
||||
import s from './index.module.css'
|
||||
import type { SuccessInvitationResult } from '.'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { randomString } from '@/utils'
|
||||
|
||||
type IInvitationLinkProps = {
|
||||
value: SuccessInvitationResult
|
||||
}
|
||||
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
const InvitationLink = ({
|
||||
value,
|
||||
}: IInvitationLinkProps) => {
|
||||
|
@ -7,6 +7,7 @@ import { useLanguage } from '../hooks'
|
||||
import { Group } from '@/app/components/base/icons/src/vender/other'
|
||||
import { OpenaiBlue, OpenaiViolet } from '@/app/components/base/icons/src/public/llm'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { renderI18nObject } from '@/hooks/use-i18n'
|
||||
|
||||
type ModelIconProps = {
|
||||
@ -28,7 +29,6 @@ const ModelIcon: FC<ModelIconProps> = ({
|
||||
return <div className='flex items-center justify-center'><OpenaiViolet className={cn('w-5 h-5', className)} /></div>
|
||||
|
||||
if (provider?.icon_small) {
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
return (
|
||||
<div className={cn('flex items-center justify-center w-5 h-5', isDeprecated && 'opacity-50', className)}>
|
||||
<img alt='model-icon' src={basePath + renderI18nObject(provider.icon_small, language)}/>
|
||||
|
@ -5,6 +5,7 @@ import { Openai } from '@/app/components/base/icons/src/vender/other'
|
||||
import { AnthropicDark, AnthropicLight } from '@/app/components/base/icons/src/public/llm'
|
||||
import { renderI18nObject } from '@/hooks/use-i18n'
|
||||
import { Theme } from '@/types/app'
|
||||
import { basePath } from '@/utils/var'
|
||||
import cn from '@/utils/classnames'
|
||||
import useTheme from '@/hooks/use-theme'
|
||||
|
||||
@ -35,7 +36,6 @@ const ProviderIcon: FC<ProviderIconProps> = ({
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
|
||||
return (
|
||||
<div className={cn('inline-flex items-center gap-2', className)}>
|
||||
|
@ -14,6 +14,7 @@ import Type from './type'
|
||||
import Category from './category'
|
||||
import Tools from './tools'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import I18n from '@/context/i18n'
|
||||
import Drawer from '@/app/components/base/drawer'
|
||||
import Button from '@/app/components/base/button'
|
||||
@ -57,7 +58,6 @@ const AddToolModal: FC<Props> = ({
|
||||
const getAllTools = async () => {
|
||||
setListLoading(true)
|
||||
const buildInTools = await fetchAllBuiltInTools()
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
if (basePath) {
|
||||
buildInTools.forEach((item) => {
|
||||
if (typeof item.icon == 'string' && !item.icon.includes(basePath))
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
RiAddLine,
|
||||
} from '@remixicon/react'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { ArrowUpRight } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||
import { Check } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { Tag01 } from '@/app/components/base/icons/src/vender/line/financeAndECommerce'
|
||||
@ -53,7 +54,7 @@ const Blocks = ({
|
||||
>
|
||||
<div className='flex items-center justify-between w-full pl-3 pr-1 h-[22px] text-xs font-medium text-gray-500'>
|
||||
{toolWithProvider.label[language]}
|
||||
<a className='hidden cursor-pointer items-center group-hover:flex' href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/tools?category=${toolWithProvider.type}`} target='_blank'>{t('tools.addToolModal.manageInTools')}<ArrowUpRight className='ml-0.5 w-3 h-3' /></a>
|
||||
<a className='hidden cursor-pointer items-center group-hover:flex' href={`${basePath}/tools?category=${toolWithProvider.type}`} target='_blank'>{t('tools.addToolModal.manageInTools')}<ArrowUpRight className='ml-0.5 w-3 h-3' /></a>
|
||||
</div>
|
||||
{list.map((tool) => {
|
||||
const labelContent = (() => {
|
||||
|
@ -9,6 +9,7 @@ import { AuthHeaderPrefix, AuthType, CollectionType } from '../types'
|
||||
import type { Collection, CustomCollectionBackend, Tool, WorkflowToolProviderRequest, WorkflowToolProviderResponse } from '../types'
|
||||
import ToolItem from './tool-item'
|
||||
import cn from '@/utils/classnames'
|
||||
import { basePath } from '@/utils/var'
|
||||
import I18n from '@/context/i18n'
|
||||
import { getLanguage } from '@/i18n/language'
|
||||
import Confirm from '@/app/components/base/confirm'
|
||||
@ -276,7 +277,7 @@ const ProviderDetail = ({
|
||||
variant='primary'
|
||||
className={cn('shrink-0 my-3 w-[183px]')}
|
||||
>
|
||||
<a className='flex items-center text-text-primary' href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/app/${(customCollection as WorkflowToolProviderResponse).workflow_app_id}/workflow`} rel='noreferrer' target='_blank'>
|
||||
<a className='flex items-center text-text-primary' href={`${basePath}/app/${(customCollection as WorkflowToolProviderResponse).workflow_app_id}/workflow`} rel='noreferrer' target='_blank'>
|
||||
<div className='system-sm-medium'>{t('tools.openInStudio')}</div>
|
||||
<LinkExternal02 className='ml-1 w-4 h-4' />
|
||||
</a>
|
||||
|
@ -59,6 +59,7 @@ import { CollectionType } from '@/app/components/tools/types'
|
||||
import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/iteration-start/constants'
|
||||
import { CUSTOM_LOOP_START_NODE } from '@/app/components/workflow/nodes/loop-start/constants'
|
||||
import { useWorkflowConfig } from '@/service/use-workflow'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { canFindTool } from '@/utils'
|
||||
|
||||
export const useIsChatMode = () => {
|
||||
@ -440,7 +441,6 @@ export const useWorkflow = () => {
|
||||
}
|
||||
|
||||
export const useFetchToolsData = () => {
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
const workflowStore = useWorkflowStore()
|
||||
|
||||
const handleFetchAllTools = useCallback(async (type: string) => {
|
||||
|
@ -3,6 +3,7 @@ import { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import useSWR from 'swr'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
import { basePath } from '@/utils/var'
|
||||
import cn from 'classnames'
|
||||
import { CheckCircleIcon } from '@heroicons/react/24/solid'
|
||||
import Input from '../components/base/input'
|
||||
@ -163,7 +164,7 @@ const ChangePasswordForm = () => {
|
||||
</div>
|
||||
<div className="w-full mx-auto mt-6">
|
||||
<Button variant='primary' className='w-full'>
|
||||
<a href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/signin`}>{t('login.passwordChanged')}</a>
|
||||
<a href={`${basePath}/signin`}>{t('login.passwordChanged')}</a>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import Loading from '../components/base/loading'
|
||||
import Input from '../components/base/input'
|
||||
import Button from '@/app/components/base/button'
|
||||
|
||||
import { basePath } from '@/utils/var'
|
||||
import {
|
||||
fetchInitValidateStatus,
|
||||
fetchSetupStatus,
|
||||
@ -70,7 +70,7 @@ const ForgotPasswordForm = () => {
|
||||
fetchSetupStatus().then((res: SetupStatusResponse) => {
|
||||
fetchInitValidateStatus().then((res: InitValidateStatusResponse) => {
|
||||
if (res.status === 'not_started')
|
||||
window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH || ''}/init`
|
||||
window.location.href = `${basePath}/init`
|
||||
})
|
||||
|
||||
setLoading(false)
|
||||
|
@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation'
|
||||
import Toast from '../components/base/toast'
|
||||
import Loading from '../components/base/loading'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { fetchInitValidateStatus, initValidate } from '@/service/common'
|
||||
import type { InitValidateStatusResponse } from '@/models/common'
|
||||
|
||||
@ -41,7 +42,7 @@ const InitPasswordPopup = () => {
|
||||
useEffect(() => {
|
||||
fetchInitValidateStatus().then((res: InitValidateStatusResponse) => {
|
||||
if (res.status === 'finished')
|
||||
window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH || ''}/install`
|
||||
window.location.href = `${basePath}/install`
|
||||
else
|
||||
setLoading(false)
|
||||
})
|
||||
|
@ -1,13 +1,12 @@
|
||||
'use client'
|
||||
|
||||
import { basePath } from '@/utils/var'
|
||||
import { useEffect } from 'react'
|
||||
import { usePathname } from 'next/navigation'
|
||||
|
||||
export default function RoutePrefixHandle() {
|
||||
const pathname = usePathname()
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||
console.log('basePath:', basePath)
|
||||
|
||||
const handleRouteChange = () => {
|
||||
console.log('已切换到:', pathname)
|
||||
const addPrefixToImg = (e) => {
|
||||
|
@ -18,7 +18,6 @@ export NEXT_PUBLIC_API_PREFIX=${CONSOLE_API_URL}/console/api
|
||||
export NEXT_PUBLIC_PUBLIC_API_PREFIX=${APP_API_URL}/api
|
||||
export NEXT_PUBLIC_MARKETPLACE_API_PREFIX=${MARKETPLACE_API_URL}/api/v1
|
||||
export NEXT_PUBLIC_MARKETPLACE_URL_PREFIX=${MARKETPLACE_URL}
|
||||
export NEXT_PUBLIC_BASE_PATH=${NEXT_PUBLIC_BASE_PATH}
|
||||
|
||||
export NEXT_PUBLIC_SENTRY_DSN=${SENTRY_DSN}
|
||||
export NEXT_PUBLIC_SITE_ABOUT=${SITE_ABOUT}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { basePath } from '@/utils/var'
|
||||
const { codeInspectorPlugin } = require('code-inspector-plugin')
|
||||
const withMDX = require('@next/mdx')({
|
||||
extension: /\.mdx?$/,
|
||||
@ -14,7 +15,7 @@ const withMDX = require('@next/mdx')({
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
|
||||
basePath: basePath,
|
||||
webpack: (config, { dev, isServer }) => {
|
||||
config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }))
|
||||
return config
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { API_PREFIX, IS_CE_EDITION, PUBLIC_API_PREFIX } from '@/config'
|
||||
import { refreshAccessTokenOrRelogin } from './refresh-token'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { basePath } from '@/utils/var'
|
||||
import type { AnnotationReply, MessageEnd, MessageReplace, ThoughtItem } from '@/app/components/base/chat/chat/type'
|
||||
import type { VisionFile } from '@/types/app'
|
||||
import type {
|
||||
@ -466,7 +467,7 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
const errResp: Response = err as any
|
||||
if (errResp.status === 401) {
|
||||
const [parseErr, errRespData] = await asyncRunSafe<ResponseError>(errResp.json())
|
||||
const loginUrl = `${globalThis.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH || ''}/signin`
|
||||
const loginUrl = `${globalThis.location.origin}${basePath}/signin`
|
||||
if (parseErr) {
|
||||
globalThis.location.href = loginUrl
|
||||
return Promise.reject(err)
|
||||
@ -498,11 +499,11 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_init_validated' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH || ''}/init`
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/init`
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_setup' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH || ''}/install`
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/install`
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
||||
@ -510,7 +511,7 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
const [refreshErr] = await asyncRunSafe(refreshAccessTokenOrRelogin(TIME_OUT))
|
||||
if (refreshErr === null)
|
||||
return baseFetch<T>(url, options, otherOptionsForBaseFetch)
|
||||
if (location.pathname !== `${process.env.NEXT_PUBLIC_BASE_PATH || ''}/signin` || !IS_CE_EDITION) {
|
||||
if (location.pathname !== `${basePath}/signin` || !IS_CE_EDITION) {
|
||||
globalThis.location.href = loginUrl
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
@ -104,3 +104,7 @@ export const getVars = (value: string) => {
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
// Set the value of basePath
|
||||
// example: /dify
|
||||
export const basePath = '';
|
||||
|
Loading…
Reference in New Issue
Block a user