Use public API_BASE for OnlyOffice URLs and revert IP rewriting hack to fix Docker networking
Some checks failed
Automated Container Build / build-and-push (push) Failing after 1m7s

This commit is contained in:
Elijah 2026-05-24 12:10:33 -07:00
parent 7de186ee05
commit fd26a165ba
2 changed files with 3 additions and 12 deletions

View file

@ -52,9 +52,6 @@ func (h *OnlyOfficeHandler) Callback(c *fiber.Ctx) error {
// If the server cannot resolve the public URL due to hairpin NAT, // If the server cannot resolve the public URL due to hairpin NAT,
// we can rewrite it to use the internal Docker IP // we can rewrite it to use the internal Docker IP
downloadUrl := req.Url 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 // Download modified file from Document Server
resp, err := http.Get(downloadUrl) resp, err := http.Get(downloadUrl)

View file

@ -45,16 +45,10 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit
const API_BASE = getApiBase(); const API_BASE = getApiBase();
// Use the internal backend URL for OnlyOffice server-to-server communication // Use the public API_BASE which correctly routes through the Nginx proxy to the Next.js frontend
// to avoid Hairpin NAT/DNS issues from inside the Docker network. const fileUrl = `${API_BASE}/files/download/?path=${encodeURIComponent(file.path)}&token=${downloadToken}`;
const INTERNAL_BACKEND_URL = 'http://192.168.50.57:5827'; 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 = { const baseConfig: any = {
document: { document: {
fileType: file.name.split('.').pop() || 'docx', fileType: file.name.split('.').pop() || 'docx',