diff --git a/apps/gitness/src/components-v2/file-content-viewer.tsx b/apps/gitness/src/components-v2/file-content-viewer.tsx index afb586655..6a0a9d9be 100644 --- a/apps/gitness/src/components-v2/file-content-viewer.tsx +++ b/apps/gitness/src/components-v2/file-content-viewer.tsx @@ -11,6 +11,7 @@ import { useRoutes } from '../framework/context/NavigationContext' import { useThemeStore } from '../framework/context/ThemeContext' import { useDownloadRawFile } from '../framework/hooks/useDownloadRawFile' import { useGetRepoRef } from '../framework/hooks/useGetRepoPath' +import { useIsMFE } from '../framework/hooks/useIsMFE' import useCodePathDetails from '../hooks/useCodePathDetails' import { themes } from '../pages-v2/pipeline/pipeline-edit/theme/monaco-theme' import { useRepoBranchesStore } from '../pages-v2/repo/stores/repo-branches-store' @@ -33,6 +34,7 @@ interface FileContentViewerProps { export default function FileContentViewer({ repoContent }: FileContentViewerProps) { const routes = useRoutes() const { spaceId, repoId } = useParams() + const isMFE = useIsMFE() const fileName = repoContent?.name || '' const language = filenameToLanguage(fileName) || '' const fileContent = decodeGitContent(repoContent?.content?.data) @@ -41,7 +43,7 @@ export default function FileContentViewer({ repoContent }: FileContentViewerProp const parentPath = fullResourcePath?.split(FILE_SEPERATOR).slice(0, -1).join(FILE_SEPERATOR) const downloadFile = useDownloadRawFile() const navigate = useNavigate() - const rawURL = `/api/v1/repos/${repoRef}/raw/${fullResourcePath}?git_ref=${fullGitRef}` + const rawURL = `${isMFE ? '/code' : ''}/api/v1/repos/${repoRef}/raw/${fullResourcePath}?git_ref=${fullGitRef}` const [view, setView] = useState(getDefaultView(language)) const [isDeleteFileDialogOpen, setIsDeleteFileDialogOpen] = useState(false) const { selectedBranchTag } = useRepoBranchesStore() diff --git a/apps/gitness/src/framework/hooks/useDownloadRawFile.ts b/apps/gitness/src/framework/hooks/useDownloadRawFile.ts index ae3951c92..7372779d3 100644 --- a/apps/gitness/src/framework/hooks/useDownloadRawFile.ts +++ b/apps/gitness/src/framework/hooks/useDownloadRawFile.ts @@ -2,6 +2,8 @@ import { useCallback } from 'react' import { useMutation } from '@tanstack/react-query' +import { useIsMFE } from './useIsMFE' + interface UseDownloadRawFileParams { repoRef: string resourcePath: string @@ -10,8 +12,9 @@ interface UseDownloadRawFileParams { } export function useDownloadRawFile() { + const isMFE = useIsMFE() const mutation = useMutation(async ({ repoRef, resourcePath, gitRef }: UseDownloadRawFileParams) => { - const url = `/api/v1/repos/${repoRef}/raw/${resourcePath}?git_ref=${gitRef ?? ''}` + const url = `${isMFE ? '/code' : ''}/api/v1/repos/${repoRef}/raw/${resourcePath}?git_ref=${gitRef ?? ''}` const response = await fetch(url) if (!response.ok) {