Skip to content

Commit c4579d2

Browse files
committed
Fix service worker not loading
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 2a3608d commit c4579d2

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
@@ -18,6 +18,11 @@ router.get("/(:commit)(/*)?", async (req, res) => {
1818
throw new HttpError("Not Found", HttpCode.NotFound)
1919
}
2020

21+
// Without this the default is to use the directory the script loaded from.
22+
if (req.headers["service-worker"]) {
23+
res.header("service-worker-allowed", "/")
24+
}
25+
2126
const resourcePath = path.resolve(req.params[0])
2227

2328
// Make sure it's in code-server if you aren't authenticated. This lets

0 commit comments

Comments
 (0)