How to use the http-proxy-middleware.createProxyMiddleware function in http-proxy-middleware

To help you get started, we’ve selected a few http-proxy-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pingcap / tidb-dashboard / ui / src / setupProxy.js View on Github external
module.exports = function (app) {
  // Proxy the `data.js` trick to the backend server.
  // Proxy http://localhost:3001/dashboard/api/diagnose/reports/*/data.js to
  // http://http://127.0.0.1:12333/dashboard/api/diagnose/reports/*/data.js
  app.use(
    '/',
    createProxyMiddleware('/dashboard/api/diagnose/reports/*/data.js', {
      target: dashboardApiPrefix,
      changeOrigin: true,
    })
  )

  // Rewrite the webpage to our static HTML.
  // Rewrite http://localhost:3001/dashboard/api/diagnose/reports/*/detail
  // to http://localhost:3001/dashboard/diagnoseReport.html
  app.use('/dashboard/api/diagnose/reports/:id/detail', function (req, res) {
    req.url = paths.publicUrlOrPath + 'diagnoseReport.html'
    app.handle(req, res)
  })
}
github dotnetcore / WTM / demo / WalkingTec.Mvvm.Next / ClientApp / packages / www-react / src / setupProxy.js View on Github external
module.exports = (app) => {
    app.use(proxy('/api', {
        // target: 'http://118.178.132.249:7778/',
        target: 'http://localhost:5555/',
        changeOrigin: true,
        logLevel: "debug"
    }));
    // mock(app);
};
github pennlabs / penn-courses / frontend / alert / server.js View on Github external
Object.keys(devProxy).forEach(function(context) {
                    server.use(
                        createProxyMiddleware(context, devProxy[context])
                    );
                });
                /* eslint-enable */
github AdguardTeam / AdGuardHome / client2 / scripts / webpack / webpack.config.dev.js View on Github external
const { merge } = require('webpack-merge');
const path = require('path');
const proxy = require('http-proxy-middleware');
const Webpack = require('webpack');

const { getDevServerConfig } = require('./helpers');
const baseConfig = require('./webpack.config.base');

const devHost = process.env.DEV_HOST
const target = getDevServerConfig();

const options = {
    target: devHost || `http://${target.host}:${target.port}`, // target host
    changeOrigin: true, // needed for virtual hosted sites
};
const apiProxy = proxy.createProxyMiddleware(options);

module.exports = merge(baseConfig, {
    mode: 'development',
    output: {
        path: path.resolve(__dirname, '../../build2'),
        filename: '[name].bundle.js',
    },
    optimization: {
        noEmitOnErrors: true,
    },
    devServer: {
        port: 4000,
        historyApiFallback: true,
        before: (app) => {
            app.use('/control', apiProxy);
            app.use(history({
github Azure-Samples / digital-twins-explorer / client / src / setupProxy.js View on Github external
module.exports = function (app) {
  app.use(
    "/api/proxy",
    createProxyMiddleware({
      changeOrigin: true,
      headers: {
        connection: "keep-alive"
      },
      target: "/",
      onProxyReq: proxyReq => {
        if (proxyReq.getHeader("origin")) {
          proxyReq.removeHeader("origin");
          proxyReq.removeHeader("referer");
        }
      },
      pathRewrite: path => path.replace("/api/proxy", ""),
      router: req => `https://${req.headers["x-adt-host"]}/`
    })
  );
};
github VNG-Realisatie / nlx / management-ui / src / setupProxy.js View on Github external
module.exports = function (app) {
  app.use(
    '/api',
    createProxyMiddleware({ target: getProxyUrl(process.env.PROXY) }),
  )
  app.use(
    '/oidc',
    createProxyMiddleware({ target: getProxyUrl(process.env.PROXY) }),
  )
}
github diyhue / diyHue / BridgeEmulator / web-ui-src / src / setupProxy.js View on Github external
module.exports = function (app) {
  app.use(
    "/api",
    createProxyMiddleware({
      target: "http://10.0.0.19",
      changeOrigin: true,
    })
  );
};
github VNG-Realisatie / nlx / insight-ui / src / setupProxy.js View on Github external
module.exports = function (app) {
  app.use(
    '/api',
    createProxyMiddleware({ target: getProxyUrl(process.env.PROXY) }),
  )
}
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / .storybook / middleware.js View on Github external
module.exports = function expressMiddleware(router) {
  if (target) {
    router.use('/_status', proxy.createProxyMiddleware({
      target,
      changeOrigin: true
    }))
  }
}
github pennlabs / penn-courses / frontend / plan / server.js View on Github external
Object.keys(devProxy).forEach(function (context) {
                    server.use(createProxyMiddleware(context, devProxy[context]));
                });
            }

http-proxy-middleware

The one-liner node.js proxy middleware for connect, express, next.js and more

MIT
Latest version published 25 days ago

Package Health Score

91 / 100
Full package analysis