fix(wopi): support OXICLOUD_WOPI_PUBLIC_BASE_URL env var for Docker deployments

The WOPI integration was not loading documents because the code only read
OXICLOUD_WOPI_BASE_URL, but the documentation and docker-compose examples
used OXICLOUD_WOPI_PUBLIC_BASE_URL. When only WOPI_PUBLIC_BASE_URL was set,
the wopi_base_url defaulted to config.base_url() which resolved to the
internal Docker hostname instead of the public URL.

Fixes #230.
This commit is contained in:
BillionClaw
2026-03-24 06:43:43 +08:00
parent 628707e884
commit 7c76b1f04d
+13 -1
View File
@@ -139,7 +139,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
&app_state.wopi_lock_service,
&app_state.wopi_discovery_service,
) {
// WOPI_BASE_URL: the URL OnlyOffice/Collabora uses to call back into OxiCloud
// WOPI_PUBLIC_BASE_URL: the URL the browser uses to reach OxiCloud
// Both must be set for Docker/multi-host deployments. WOPI_BASE_URL takes
// precedence if both are set (supports the legacy single-URL pattern).
let wopi_base_url = std::env::var("OXICLOUD_WOPI_BASE_URL")
.or_else(|_| std::env::var("OXICLOUD_WOPI_PUBLIC_BASE_URL"))
.map(|v| v.trim_end_matches('/').to_string())
.ok()
.filter(|v| !v.is_empty())
.unwrap_or_else(|| config.base_url());
let public_base_url = std::env::var("OXICLOUD_WOPI_PUBLIC_BASE_URL")
.or_else(|_| std::env::var("OXICLOUD_WOPI_BASE_URL"))
.map(|v| v.trim_end_matches('/').to_string())
.ok()
.filter(|v| !v.is_empty())
@@ -150,7 +162,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
lock_service: lock_svc.clone(),
discovery_service: discovery_svc.clone(),
app_state: app_state.clone(),
public_base_url: config.base_url(),
public_base_url,
wopi_base_url,
};