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" "fmt"
"io" "io"
"net/http" "net/http"
"net/url"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -663,30 +664,33 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
// Build WOPISrc URL // Build WOPISrc URL
wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s?access_token=%s", fileID, accessToken) 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 // Return HTML page with auto-submitting form
htmlContent := fmt.Sprintf(`<!DOCTYPE html> htmlContent := fmt.Sprintf(`<!DOCTYPE html>
<html> <html>
<head> <head>
<title>Loading Document...</title> <title>Loading Document...</title>
<style> <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; } .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> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="message">Loading document in Collabora Online...</div> <div class="message">Loading document in Collabora Online...</div>
</div> </div>
<form method="POST" action="%s/loleaflet/dist/loleaflet.html" id="collaboraForm" style="display: none;"> <iframe id="collabora-frame" style="display:none; width:100%%; height:100%%; border:none;"></iframe>
<input type="hidden" name="WOPISrc" value="%s">
</form>
<script> <script>
// Submit the form immediately to Collabora // Load Collabora editor in iframe
document.getElementById('collaboraForm').submit(); var frame = document.getElementById('collabora-frame');
frame.style.display = 'block';
frame.src = '%s';
</script> </script>
</body> </body>
</html>`, collaboraURL, wopiSrc) </html>`, collaboraEditorURL)
w.Header().Set("Content-Type", "text/html; charset=utf-8") 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 // Don't set X-Frame-Options - this endpoint is meant to be loaded in an iframe