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.
This commit is contained in:
Asher 2020-11-19 10:18:15 -06:00 committed by GitHub
parent 08b9e9ad1f
commit 72caafe8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -52,6 +52,11 @@ router.get("/(:commit)(/*)?", async (req, res) => {
res.header("Cache-Control", "public, max-age=31536000")
}
// Without this the default is to use the directory the script loaded from.
if (req.headers["service-worker"]) {
res.header("service-worker-allowed", "/")
}
res.set("Content-Type", getMediaMime(resourcePath))
if (resourcePath.endsWith("manifest.json")) {