don’t proxy custom service worker files

This commit is contained in:
Hans Pagel committed 2023-02-13 17:50:08 +01:00
1 parent b0bf08e2a7
commit 6d5a6fd71a
1 file changed
+17 -20
+17 -20
View File
@@ -23,30 +23,27 @@ const router = new Router();
koa.use<BaseContext, UserAgentContext>(userAgent);
// serve public assets
router.use(
["/images/*", "/email/*", "/sw.js", "/registerSW.js"],
async (ctx, next) => {
let done;
router.use(["/images/*", "/email/*"], async (ctx, next) => {
let done;
if (ctx.method === "HEAD" || ctx.method === "GET") {
try {
done = await send(ctx, ctx.path, {
root: path.resolve(__dirname, "../../../public"),
// 7 day expiry, these assets are mostly static but do not contain a hash
maxAge: 7 * 24 * 60 * 60 * 1000,
});
} catch (err) {
if (err.status !== 404) {
throw err;
}
if (ctx.method === "HEAD" || ctx.method === "GET") {
try {
done = await send(ctx, ctx.path, {
root: path.resolve(__dirname, "../../../public"),
// 7 day expiry, these assets are mostly static but do not contain a hash
maxAge: 7 * 24 * 60 * 60 * 1000,
});
} catch (err) {
if (err.status !== 404) {
throw err;
}
}
if (!done) {
await next();
}
}
);
if (!done) {
await next();
}
});
router.use(
["/share/:shareId", "/share/:shareId/doc/:documentSlug", "/share/:shareId/*"],