From be087f67657fa86c54171d16f87e508d696ef244 Mon Sep 17 00:00:00 2001 From: LB Date: Wed, 6 Nov 2024 06:47:30 +1000 Subject: [PATCH] Update middleware to support changes in Storybook v8 Fixes #14 --- src/middleware.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/middleware.js b/src/middleware.js index ad32525..caf50bf 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -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;