Revert to form POST submission to /cool/dist/cool.html (correct WOPI pattern)

- Collabora Online requires POST request with WOPISrc in form body
- GET requests with query parameters cause 400 Bad Request
- Using modern /cool/ endpoint with form submission to iframe
This commit is contained in:
Leon Bösche
2026-01-13 00:13:21 +01:00
parent d255f40a8c
commit 57eea172a2

View File

@@ -5,7 +5,8 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url"
//"net/url"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -664,11 +665,8 @@ 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 // Return HTML page with auto-submitting form
// Collabora expects: /cool/dist/cool.html?WOPISrc=... // Collabora Online requires: POST to /cool/dist/cool.html with WOPISrc in request body
editorURL := fmt.Sprintf("%s/cool/dist/cool.html?WOPISrc=%s&closebutton=1", collaboraURL, url.QueryEscape(wopiSrc))
// Return HTML page that loads Collabora in an iframe
htmlContent := fmt.Sprintf(`<!DOCTYPE html> htmlContent := fmt.Sprintf(`<!DOCTYPE html>
<html> <html>
<head> <head>
@@ -677,39 +675,33 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
<style> <style>
* { margin: 0; padding: 0; box-sizing: border-box; } * { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%%; height: 100%%; overflow: hidden; } html, body { width: 100%%; height: 100%%; overflow: hidden; }
#collabora-container { width: 100%%; height: 100%%; background: #f5f5f5; } .loading { position: fixed; top: 50%%; left: 50%%; transform: translate(-50%%, -50%%); text-align: center; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
#collabora-frame { width: 100%%; height: 100%%; border: none; } .loading p { color: #666; margin-top: 10px; font-family: system-ui, sans-serif; }
.loading { position: absolute; top: 50%%; left: 50%%; transform: translate(-50%%, -50%%); text-align: center; }
.loading p { color: #666; margin-top: 10px; }
</style> </style>
</head> </head>
<body> <body>
<div id="collabora-container">
<div class="loading"> <div class="loading">
<p>Loading Collabora Online...</p> <p>Loading Collabora Online...</p>
</div> </div>
<iframe id="collabora-frame"></iframe> <form method="POST" action="%s/cool/dist/cool.html" target="collabora-frame" id="collaboraForm" style="display: none;">
</div> <input type="hidden" name="WOPISrc" value="%s">
</form>
<iframe name="collabora-frame" id="collabora-frame" style="position:fixed; top:0; left:0; width:100%%; height:100%%; border:none;"></iframe>
<script> <script>
window.addEventListener('load', function() { window.addEventListener('load', function() {
var frame = document.getElementById('collabora-frame'); setTimeout(function() {
var loading = document.querySelector('.loading'); var form = document.getElementById('collaboraForm');
if (form) {
if (frame) { console.log('[COLLABORA] Submitting form to /cool/dist/cool.html');
frame.onload = function() { form.submit();
if (loading) loading.style.display = 'none'; } else {
}; console.error('[COLLABORA] Form not found');
frame.onerror = function() {
console.error('[COLLABORA] Frame load error');
};
console.log('[COLLABORA] Loading editor from:', '%s');
frame.src = '%s';
} }
}, 100);
}); });
</script> </script>
</body> </body>
</html>`, editorURL, editorURL) </html>`, collaboraURL, wopiSrc)
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