1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-21 19:12:10 +01:00

Serve wabac service worker from static prefix

This commit is contained in:
Tessa Walsh 2025-03-19 12:40:09 -04:00
parent d6bb03409f
commit d2eb934b8d
3 changed files with 5 additions and 4 deletions

View File

@ -133,7 +133,7 @@ class FrontEndApp(object):
self.url_map.add(Rule('/', endpoint=self.serve_home))
if self.client_side_replay:
self.url_map.add(Rule('/static/sw.js', endpoint=self.serve_wabac_service_worker))
self.url_map.add(Rule('/{0}/sw.js'.format(self.static_prefix), endpoint=self.serve_wabac_service_worker))
self._init_coll_routes(coll_prefix)

View File

@ -1,9 +1,10 @@
class WabacReplay
{
constructor(prefix, url, ts) {
constructor(prefix, url, ts, staticPrefix) {
this.prefix = prefix;
this.url = url;
this.ts = ts;
this.staticPrefix = staticPrefix;
this.collName = new URL(prefix, "http://dummy").pathname.split('/')[1];
this.adblockUrl = undefined;
@ -14,7 +15,7 @@ class WabacReplay
const scope = "/";
await navigator.serviceWorker.register(
"/static/sw.js?" + new URLSearchParams(this.queryParams).toString(),
`${this.staticPrefix}/sw.js?` + new URLSearchParams(this.queryParams).toString(),
{ scope },
);

View File

@ -16,7 +16,7 @@ html, body
{% if client_side_replay %}
<script src='{{ static_prefix }}/loadWabac.js'></script>
<script>
new WabacReplay("{{ wb_prefix }}", "{{ url }}", "{{ timestamp }}").init();
new WabacReplay("{{ wb_prefix }}", "{{ url }}", "{{ timestamp }}", "{{ static_prefix }}").init();
</script>
{% else %}
<script src='{{ static_prefix }}/wb_frame.js'> </script>