diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index a3c54ed2..919cde76 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -17,8 +17,14 @@ const serviceApi = (path: string) => initialize({}, [ rest.get(nextApi('/service-api/*'), async (req, res, ctx) => { - const [_, path] = req.url.pathname.split('/service-api'); + const { pathname } = req.url; + const match = /\/service-api(?.*)/g.exec(pathname); + if (!match || !match.groups || !match.groups.path) { + return res(ctx.status(404, 'Invalid Request URL')); + } + + const { path } = match.groups; const originResponse = await ctx.fetch(serviceApi(`/api${path}`)); const originResponseData = await originResponse.json(); diff --git a/package.json b/package.json index 513a413e..97bbcacf 100644 --- a/package.json +++ b/package.json @@ -76,4 +76,4 @@ "msw": { "workerDirectory": "public" } -} \ No newline at end of file +}