Skip to content

Commit 446d9e3

Browse files
committed
fix(files): only rewrite relative workspace file URLs to avoid hydration mismatch
1 parent 2d3993f commit 446d9e3

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import 'prismjs/components/prism-sql'
2222
import 'prismjs/components/prism-python'
2323
import { cn } from '@/lib/core/utils/cn'
2424
import { extractTextContent } from '@/lib/core/utils/react-node-text'
25-
import { getBrowserOrigin } from '@/lib/core/utils/urls'
2625
import { getFileExtension } from '@/lib/uploads/utils/file-utils'
2726
import { useAutoScroll } from '@/hooks/use-auto-scroll'
2827
import { DataTable } from './data-table'
@@ -477,11 +476,7 @@ function resolveSimFileUrl(src: string | undefined): string | undefined {
477476
if (!src) return src
478477
try {
479478
const parsed = new URL(src, 'http://placeholder')
480-
const isRelative = parsed.origin === 'http://placeholder'
481-
const browserOrigin = getBrowserOrigin()
482-
// null means SSR — treat as same-origin so server and client produce identical output
483-
const isSameOrigin = browserOrigin === null || parsed.origin === browserOrigin
484-
if (!isRelative && !isSameOrigin) return src
479+
if (parsed.origin !== 'http://placeholder') return src
485480
const [, seg1, , seg3, fileId] = parsed.pathname.split('/')
486481
if (seg1 === 'workspace' && seg3 === 'files' && fileId) {
487482
return `/api/files/view/${fileId}`

0 commit comments

Comments
 (0)