From a343f76a3a511369b3f48492a9f2c896649a3075 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 27 Jan 2023 18:58:52 -0600 Subject: [PATCH] Update to take port optionally from process.env.REACT_APP_PROXY_LOCALHOST_PORT; more explict mapping of all paths that javalin backend exposes --- src/setupProxy.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/setupProxy.js b/src/setupProxy.js index d6d896c..256a94f 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -29,19 +29,27 @@ const {createProxyMiddleware} = require("http-proxy-middleware"); module.exports = function (app) { - app.use( - "/data/*/export/*", - createProxyMiddleware({ - target: "http://localhost:8000", - changeOrigin: true, - }), - ); + let port = 8000; + if(process.env.REACT_APP_PROXY_LOCALHOST_PORT) + { + port = process.env.REACT_APP_PROXY_LOCALHOST_PORT; + } - app.use( - "/download/*", - createProxyMiddleware({ - target: "http://localhost:8000", + function getRequestHandler() + { + return createProxyMiddleware({ + target: `http://localhost:${port}`, changeOrigin: true, - }), - ); + }); + } + + app.use("/data/*/export/*", getRequestHandler()); + app.use("/download/*", getRequestHandler()); + app.use("/metaData/*", getRequestHandler()); + app.use("/data/*", getRequestHandler()); + app.use("/widget/*", getRequestHandler()); + app.use("/serverInfo", getRequestHandler()); + app.use("/processes", getRequestHandler()); + app.use("/reports", getRequestHandler()); + };