Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feature: support loading pwa-worker from subdir (#13156)

Aaron van Meerten78bdbe2c3fdc
diff --git a/doc/debian/jitsi-meet/jitsi-meet.example b/doc/debian/jitsi-meet/jitsi-meet.example
index bcf26688f9..1df9e15a79 100644
--- a/doc/debian/jitsi-meet/jitsi-meet.example
+++ b/doc/debian/jitsi-meet/jitsi-meet.example
@@ -157,6 +157,13 @@ server {
alias /etc/jitsi/meet/jitsi-meet.example.com-config.js;
}
+ # Matches /(TENANT)/pwa-worker.js or /(TENANT)/manifest.json to rewrite to / and look for file
+ location ~ ^/([^/?&:'"]+)/(pwa-worker.js|manifest.json)$ {
+ set $subdomain "$1.";
+ set $subdir "$1/";
+ rewrite ^/([^/?&:'"]+)/(pwa-worker.js|manifest.json)$ /$2;
+ }
+
# BOSH for subdomains
location ~ ^/([^/?&:'"]+)/http-bind {
set $subdomain "$1.";
diff --git a/index.html b/index.html
index 56d8ef0924..51196cf0c1 100644
--- a/index.html
+++ b/index.html
@@ -13,10 +13,19 @@
<link rel="manifest" id="manifest-placeholder">
<script>
+ function contextRoot(pathname) {
+ const contextRootEndIndex = pathname.lastIndexOf('/');
+
+ return (
+ contextRootEndIndex === -1
+ ? '/'
+ : pathname.substring(0, contextRootEndIndex + 1)
+ );
+ }
window.EXCALIDRAW_ASSET_PATH = 'libs/';
// Dynamically generate the manifest location URL. It must be served from the document origin, and we may have
// the base pointing to the CDN. This way we can generate a full URL which will bypass the base.
- document.querySelector('#manifest-placeholder').setAttribute('href', window.location.origin + '/manifest.json');
+ document.querySelector('#manifest-placeholder').setAttribute('href', window.location.origin + contextRoot(window.location.pathname) + 'manifest.json');
document.addEventListener('DOMContentLoaded', () => {
if (!JitsiMeetJS.app) {
@@ -40,7 +49,7 @@
if (shouldRegisterWorker) {
navigator.serviceWorker
- .register(window.location.origin + '/pwa-worker.js')
+ .register(window.location.origin + contextRoot(window.location.pathname) + '/pwa-worker.js')
.then(reg => {
console.log('Service worker registered.', reg);
})