Skip to content

Commit 72caafe

Browse files
authored
Fix service worker not loading (#2335)
I removed this under the impression the default was to allow it anywhere but that's not the case. Since the service worker was already registered in my browser I never got the error during testing.
1 parent 08b9e9a commit 72caafe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/node/routes/static.ts

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ router.get("/(:commit)(/*)?", async (req, res) => {
5252
res.header("Cache-Control", "public, max-age=31536000")
5353
}
5454

55+
// Without this the default is to use the directory the script loaded from.
56+
if (req.headers["service-worker"]) {
57+
res.header("service-worker-allowed", "/")
58+
}
59+
5560
res.set("Content-Type", getMediaMime(resourcePath))
5661

5762
if (resourcePath.endsWith("manifest.json")) {

0 commit comments

Comments
 (0)