From 2920e755ecc28cca0375091ae7be19e8f3a40bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Thu, 1 Jun 2023 21:47:32 +0200 Subject: [PATCH] fix: dev plugin and base url (#528) --- src/plugins/dev.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/dev.ts b/src/plugins/dev.ts index b0403fc2..d8cdb08f 100644 --- a/src/plugins/dev.ts +++ b/src/plugins/dev.ts @@ -156,10 +156,12 @@ export function DevPlugin(ctx: PWAPluginContext) { return await fs.readFile(swDest, 'utf-8') } - const key = normalizePath(`${options.base}${id.startsWith('/') ? id.slice(1) : id}`) - - if (swDevOptions.workboxPaths.has(key)) - return await fs.readFile(swDevOptions.workboxPaths.get(key)!, 'utf-8') + // check the entry only if the request starts with the base, otherwise ignore the request + if (id.startsWith(options.base)) { + const key = normalizePath(id) + if (swDevOptions.workboxPaths.has(key)) + return await fs.readFile(swDevOptions.workboxPaths.get(key)!, 'utf-8') + } } }, }