diff --git a/frontend/src/components/OnlyOfficeEditor.tsx b/frontend/src/components/OnlyOfficeEditor.tsx index aae595c..87fbc85 100644 --- a/frontend/src/components/OnlyOfficeEditor.tsx +++ b/frontend/src/components/OnlyOfficeEditor.tsx @@ -37,10 +37,16 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit ); } - const API_BASE = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080'; + const getApiBase = () => { + if (process.env.NEXT_PUBLIC_API_URL) return process.env.NEXT_PUBLIC_API_URL; + if (typeof window !== 'undefined') return window.location.origin; + return 'http://localhost:8080'; + }; + + const API_BASE = getApiBase(); // URL that OnlyOffice will use to download the file - const fileUrl = `${API_BASE}/api/files/download/${encodeURIComponent(file.path)}?token=${downloadToken}`; + const fileUrl = `${API_BASE}/api/files/download/?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; // Callback URL that OnlyOffice will post to when saving const callbackUrl = `${API_BASE}/api/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; @@ -97,7 +103,7 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit