From 076147893dbb165c4747c49894a6d55025306985 Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Sat, 21 Oct 2023 06:53:43 -0500 Subject: [PATCH] Fix proxy path mapping for /api endpoint (#142) fixes #141 Signed-off-by: Sean Sundberg --- server/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index 66aaa08..0b9c840 100644 --- a/server/index.js +++ b/server/index.js @@ -103,9 +103,17 @@ const createServer = () => { app.get(LOGOUT2_URL, logout); const apiProxy = proxy(BACKEND_HOST, { - proxyReqPathResolver: req => url.parse(req.baseUrl).path + proxyReqPathResolver: req => { + const origPath = url.parse(req.baseUrl).path + + const path = origPath.replace(/^\/api/, '') + console.log(`Proxy path: ${origPath} -> ${path}`) + + return path + } }); app.use('/api/*', apiProxy); + app.use('/api', apiProxy); const graphqlProxy = proxy(`${BACKEND_HOST}/graphql`, { proxyReqPathResolver: req => url.parse(req.baseUrl).path