
====== Onlyoffice - снятие ограничений ======

https://help.nextcloud.com/t/onlyoffice-compiled-with-mobile-edit-back/79282/330

===== Caddy =====

<code bash>
$ xcaddy build --with github.com/caddyserver/replace-response
</code>

<code>
https://my.super.domain:443 {
	# Default reverse proxy
	reverse_proxy nextcloud-aio-apache:11000

	# OnlyOffice-specific replacement rules to enable mobile-editing (premium feature)
	handle /onlyoffice/*/web-apps/apps/*/mobile/dist/js/app.js {
		reverse_proxy nextcloud-aio-apache:11000 {
			# Disable compression so replacement can work
			header_up Accept-Encoding identity
		}

		replace {
			match {
				header Content-Type application/javascript*
			}
			isSupportEditFeature=()=>!1 isSupportEditFeature=()=>!0
		}
	}
}
</code>

===== Nginx =====

Установить модуль ngx_http_sub_module

<code>
    location ~ ^/onlyoffice/.*/web-apps/apps/.*/mobile/dist/js/app\.js$ {
        proxy_pass http://nextcloud-aio-apache:11000;

        # Disable compression so body replacement works
        proxy_set_header Accept-Encoding "";

        sub_filter_types application/javascript;
        sub_filter "isSupportEditFeature=()=>!1" "isSupportEditFeature=()=>!0";
        sub_filter_once off;  # Replace all occurrences, not just the first
    }
</code>