Fix OnlyOffice: use internal IP for server-side URLs, create valid docx/pptx files
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m24s

This commit is contained in:
Elijah 2026-05-24 12:41:31 -07:00
parent 382d78d492
commit a0353445d9
2 changed files with 139 additions and 14 deletions

View file

@ -37,17 +37,14 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit
useEffect(() => {
if (!downloadToken) return;
const getApiBase = () => {
if (process.env.NEXT_PUBLIC_API_URL) return process.env.NEXT_PUBLIC_API_URL;
if (typeof window !== 'undefined') return `${window.location.origin}/api`;
return 'http://localhost:8080';
};
const API_BASE = getApiBase();
// The OnlyOffice Document Server fetches these URLs server-side (not from the browser).
// It's on the default bridge network and can reach the Unraid host IP, but NOT
// the public domain (hairpin NAT) or Docker DNS names (different network).
// Port 5827 is the frontend container (which proxies /api/* to the backend).
const INTERNAL_URL = 'http://192.168.50.81:5827/api';
// Use the public API_BASE which correctly routes through the Nginx proxy to the Next.js frontend
const fileUrl = `${API_BASE}/files/download/${encodeURIComponent(file.path)}?token=${downloadToken}`;
const callbackUrl = `${API_BASE}/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`;
const fileUrl = `${INTERNAL_URL}/files/download/${encodeURIComponent(file.path)}?token=${downloadToken}`;
const callbackUrl = `${INTERNAL_URL}/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`;
const baseConfig: any = {
document: {