From fd26a165baefdafd7adee924125f34aea05b28c1 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 24 May 2026 12:10:33 -0700 Subject: [PATCH] Use public API_BASE for OnlyOffice URLs and revert IP rewriting hack to fix Docker networking --- backend/handlers/onlyoffice.go | 3 --- frontend/src/components/OnlyOfficeEditor.tsx | 12 +++--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/backend/handlers/onlyoffice.go b/backend/handlers/onlyoffice.go index 7ca9e97..da98f00 100644 --- a/backend/handlers/onlyoffice.go +++ b/backend/handlers/onlyoffice.go @@ -52,9 +52,6 @@ func (h *OnlyOfficeHandler) Callback(c *fiber.Ctx) error { // If the server cannot resolve the public URL due to hairpin NAT, // we can rewrite it to use the internal Docker IP downloadUrl := req.Url - if strings.HasPrefix(downloadUrl, "https://office.elijahkuntz.com") { - downloadUrl = strings.Replace(downloadUrl, "https://office.elijahkuntz.com", "http://192.168.50.81:8084", 1) - } // Download modified file from Document Server resp, err := http.Get(downloadUrl) diff --git a/frontend/src/components/OnlyOfficeEditor.tsx b/frontend/src/components/OnlyOfficeEditor.tsx index 810e956..545233b 100644 --- a/frontend/src/components/OnlyOfficeEditor.tsx +++ b/frontend/src/components/OnlyOfficeEditor.tsx @@ -45,16 +45,10 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit const API_BASE = getApiBase(); - // Use the internal backend URL for OnlyOffice server-to-server communication - // to avoid Hairpin NAT/DNS issues from inside the Docker network. - const INTERNAL_BACKEND_URL = 'http://192.168.50.57:5827'; + // Use the public API_BASE which correctly routes through the Nginx proxy to the Next.js frontend + const fileUrl = `${API_BASE}/files/download/?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; + const callbackUrl = `${API_BASE}/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; - // URL that OnlyOffice will use to download the file - const fileUrl = `${INTERNAL_BACKEND_URL}/api/files/download/?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; - - // Callback URL that OnlyOffice will post to when saving - const callbackUrl = `${INTERNAL_BACKEND_URL}/api/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`; - const baseConfig: any = { document: { fileType: file.name.split('.').pop() || 'docx',