Fix: Use form POST submission for Collabora (not GET query string)
- Collabora requires POST request to /loleaflet/dist/loleaflet.html - WOPISrc must be in request body as form parameter - Form targets iframe by name for proper document loading - Matches WOPI/Collabora standard integration pattern
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -664,14 +663,13 @@ 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
|
||||
// Collabora requires: POST to /loleaflet/dist/loleaflet.html with WOPISrc in request body
|
||||
htmlContent := fmt.Sprintf(`<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Loading Document...</title>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
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; }
|
||||
@@ -682,15 +680,24 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
|
||||
<div class="container">
|
||||
<div class="message">Loading document in Collabora Online...</div>
|
||||
</div>
|
||||
<iframe id="collabora-frame" style="display:none; width:100%%; height:100%%; border:none;"></iframe>
|
||||
<form method="POST" action="%s/loleaflet/dist/loleaflet.html" target="collabora-frame" id="collaboraForm" style="display: none;">
|
||||
<input type="hidden" name="WOPISrc" value="%s">
|
||||
</form>
|
||||
<iframe name="collabora-frame" id="collabora-frame" style="width:100%%; height:100%%; border:none; position:absolute; top:0; left:0;"></iframe>
|
||||
<script>
|
||||
// Load Collabora editor in iframe
|
||||
var frame = document.getElementById('collabora-frame');
|
||||
frame.style.display = 'block';
|
||||
frame.src = '%s';
|
||||
(function() {
|
||||
var form = document.getElementById('collaboraForm');
|
||||
var frame = document.getElementById('collabora-frame');
|
||||
if (form && frame) {
|
||||
console.log('[COLLABORA] Submitting form to Collabora...');
|
||||
form.submit();
|
||||
} else {
|
||||
console.error('[COLLABORA] Form or frame element not found!');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>`, collaboraEditorURL)
|
||||
</html>`, collaboraURL, wopiSrc)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user