/ mlflow / server / js / src / setupProxy.js
setupProxy.js
 1  const { createProxyMiddleware } = require('http-proxy-middleware');
 2  
 3  // eslint-disable-next-line
 4  module.exports = function (app) {
 5    // The MLflow Gunicorn server is running on port 5000, so we should redirect server requests
 6    // (eg /ajax-api) to that port.
 7    // Exception: If the caller has specified an MLFLOW_PROXY, we instead forward server requests
 8    // there.
 9    // eslint-disable-next-line no-undef
10    const proxyTarget = process.env.MLFLOW_PROXY || 'http://localhost:5000/';
11    // eslint-disable-next-line no-undef
12    const proxyStaticTarget = process.env.MLFLOW_STATIC_PROXY || proxyTarget;
13    app.use(
14      createProxyMiddleware('/ajax-api', {
15        target: proxyTarget,
16        changeOrigin: true,
17      }),
18    );
19    app.use(
20      createProxyMiddleware('/graphql', {
21        target: proxyTarget,
22        changeOrigin: true,
23      }),
24    );
25    app.use(
26      createProxyMiddleware('/get-artifact', {
27        target: proxyStaticTarget,
28        ws: true,
29        changeOrigin: true,
30      }),
31    );
32    app.use(
33      createProxyMiddleware('/model-versions/get-artifact', {
34        target: proxyStaticTarget,
35        ws: true,
36        changeOrigin: true,
37      }),
38    );
39    app.use(
40      createProxyMiddleware('/gateway', {
41        target: proxyTarget,
42        changeOrigin: true,
43      }),
44    );
45  };