Skip to content

Commit

Permalink
Update middleware to support changes in Storybook v8
Browse files Browse the repository at this point in the history
  • Loading branch information
lb- committed Nov 5, 2024
1 parent 93a870e commit be087f6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ const restream = (proxyReq, req) => {
const createDjangoAPIMiddleware = (options) => {
const { proxy, apiPath, origin } = options;
const createProxy = proxy || createProxyMiddleware;
const paths = Array.isArray(apiPath) ? apiPath : [apiPath];
const middleware = (router) => {
router.use(
apiPath,
createProxy({
target: origin,
changeOrigin: true,
onProxyReq: restream,
}),
);
paths.forEach((path) => {
router.use(
path,
createProxy({
target: origin,
changeOrigin: true,
onProxyReq: restream,
}),
);
});
};

return middleware;
Expand Down

0 comments on commit be087f6

Please sign in to comment.