Skip to content

Commit d2eb934

Browse files
committed
Serve wabac service worker from static prefix
1 parent d6bb034 commit d2eb934

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pywb/apps/frontendapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _init_routes(self):
133133
self.url_map.add(Rule('/', endpoint=self.serve_home))
134134

135135
if self.client_side_replay:
136-
self.url_map.add(Rule('/static/sw.js', endpoint=self.serve_wabac_service_worker))
136+
self.url_map.add(Rule('/{0}/sw.js'.format(self.static_prefix), endpoint=self.serve_wabac_service_worker))
137137

138138
self._init_coll_routes(coll_prefix)
139139

pywb/static/loadWabac.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class WabacReplay
22
{
3-
constructor(prefix, url, ts) {
3+
constructor(prefix, url, ts, staticPrefix) {
44
this.prefix = prefix;
55
this.url = url;
66
this.ts = ts;
7+
this.staticPrefix = staticPrefix;
78
this.collName = new URL(prefix, "http://dummy").pathname.split('/')[1];
89
this.adblockUrl = undefined;
910

@@ -14,7 +15,7 @@ class WabacReplay
1415
const scope = "/";
1516

1617
await navigator.serviceWorker.register(
17-
"/static/sw.js?" + new URLSearchParams(this.queryParams).toString(),
18+
`${this.staticPrefix}/sw.js?` + new URLSearchParams(this.queryParams).toString(),
1819
{ scope },
1920
);
2021

pywb/templates/frame_insert.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{% if client_side_replay %}
1717
<script src='{{ static_prefix }}/loadWabac.js'></script>
1818
<script>
19-
new WabacReplay("{{ wb_prefix }}", "{{ url }}", "{{ timestamp }}").init();
19+
new WabacReplay("{{ wb_prefix }}", "{{ url }}", "{{ timestamp }}", "{{ static_prefix }}").init();
2020
</script>
2121
{% else %}
2222
<script src='{{ static_prefix }}/wb_frame.js'> </script>

0 commit comments

Comments
 (0)