Skip to content

Commit fa370d8

Browse files
author
zhouxianfu
committed
fix: sync base url and scope
1 parent 21fe6a6 commit fa370d8

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

dist/msw-tools.min.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -23426,12 +23426,13 @@ function instance($$self, $$props, $$invalidate) {
2342623426
console.log("[baseUrl]", base);
2342723427
init2();
2342823428
{
23429+
let basePath = base || "/";
2342923430
mocker.start({
2343023431
onUnhandledRequest: "bypass",
2343123432
serviceWorker: {
23432-
url: `${base || "/"}mockServiceWorker.js`,
23433+
url: `${basePath}mockServiceWorker.js`,
2343323434
options: {
23434-
scope: "/"
23435+
scope: basePath
2343523436
}
2343623437
}
2343723438
});

dist/msw-tools.min.umd.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "msw-tools",
3-
"version": "1.0.9",
3+
"version": "1.0.11",
44
"description": "Msw-tools(Mock Service Worker Tools) is an interface data mock tool for local development and testing based on Msw.js and Svelte.",
55
"main": "dist/msw-tools.min.umd.js",
66
"keywords": [

src/components/msw/index.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,18 @@
214214
init();
215215
216216
if (isProd) {
217+
let basePath = base || '/'
217218
mocker.start({
218219
// 对于没有 mock 的接口直接通过,避免异常
219220
onUnhandledRequest: "bypass",
220221
serviceWorker: {
221222
// Points to the custom location of the Service Worker file.
222223
// url: 'http://localhost:1234/mockServiceWorker.js',
223-
url: `${base || '/' }mockServiceWorker.js`,
224+
url: `${basePath}mockServiceWorker.js`,
224225
options: {
225226
// Narrow the scope of the Service Worker to intercept requests
226227
// only from pages under this path.
227-
scope: "/"
228+
scope: basePath
228229
}
229230
}
230231
});

0 commit comments

Comments
 (0)