From 9f6d70e130754fee52464a85646fb8d2dcffa41b Mon Sep 17 00:00:00 2001 From: Aram Becker Date: Wed, 26 Apr 2023 10:09:12 +0200 Subject: [PATCH] Fix: apply base path workerUrls --- server/Server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/Server.js b/server/Server.js index bc6eb8a73..bbe6ede6d 100644 --- a/server/Server.js +++ b/server/Server.js @@ -344,8 +344,11 @@ class Server { return } + const urlKeys = ["href", "src", "url", "scope", "workerUrl"].join("|"); + const alternateBaseUris = ["http://localhost:3333"].join("|"); // Matches e.g `href="/_nuxt/..."` or `src='/...'` or `"url":"http://localhost:3333/...` - const replaceUrls = new RegExp(`((?:href|src|url|scope)"?(?:=|:)\\s*["'](?:http://localhost:3333)?)${currentBasePath || "/"}([^"']*["'])`, "g") + // $1 = key + assignment operator + opening quote + alternate base, $2 = path + closing quotes + const replaceUrls = new RegExp(`((?:${urlKeys})["']?[:=]\\s*["'](?:${alternateBaseUris})?)${currentBasePath || "/"}([^"']*["'])`, "g") const replaceNuxtConfig = new RegExp(``, "g") const replaceAssetPaths = new RegExp(`${currentBasePath}/(_nuxt/[^"]*|sw.js)`, "g")