Fix: Collabora proxy should load iframe with WOPISrc in query string, not form submission

- Changed from form POST submission to direct iframe load
- WOPISrc goes in Collabora URL query string, not as form parameter
- This matches Collabora's expected request format for WOPI integration
This commit is contained in:
Leon Bösche
2026-01-12 16:40:35 +01:00
parent 18138dde01
commit d58137716f

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
"sync"
"time"
@@ -663,30 +664,33 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
// Build WOPISrc URL
wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s?access_token=%s", fileID, accessToken)
// Build Collabora editor URL with WOPISrc in query string
collaboraEditorURL := fmt.Sprintf("%s/loleaflet/dist/loleaflet.html?WOPISrc=%s", collaboraURL, url.QueryEscape(wopiSrc))
// Return HTML page with auto-submitting form
htmlContent := fmt.Sprintf(`<!DOCTYPE html>
<html>
<head>
<title>Loading Document...</title>
<style>
body { margin: 0; padding: 0; background: #f5f5f5; }
body { margin: 0; padding: 0; background: #f5f5f5; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.container { display: flex; justify-content: center; align-items: center; height: 100vh; }
.message { font-family: sans-serif; color: #666; }
.message { color: #666; font-size: 16px; }
</style>
</head>
<body>
<div class="container">
<div class="message">Loading document in Collabora Online...</div>
</div>
<form method="POST" action="%s/loleaflet/dist/loleaflet.html" id="collaboraForm" style="display: none;">
<input type="hidden" name="WOPISrc" value="%s">
</form>
<iframe id="collabora-frame" style="display:none; width:100%%; height:100%%; border:none;"></iframe>
<script>
// Submit the form immediately to Collabora
document.getElementById('collaboraForm').submit();
// Load Collabora editor in iframe
var frame = document.getElementById('collabora-frame');
frame.style.display = 'block';
frame.src = '%s';
</script>
</body>
</html>`, collaboraURL, wopiSrc)
</html>`, collaboraEditorURL)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
// Don't set X-Frame-Options - this endpoint is meant to be loaded in an iframe