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