Welcome to the Linux Foundation Forum!

Chaptet 8 - Single-Origin, Multi-Route Proxy with Express

Hi @davidmarkclements ,

Do you have any implementation example of a single origin and multiorigin proxy with express. What package would you recommend ?.



  • Hi @nayib
    For this purpose i use http-proxy-middleware lib
    var app =* express(); var proxy = require('http-proxy-middleware'); var apiProxy = proxy.createProxyMiddleware({target:'https://news.ycombinator.com/', secure:false}); app.use(apiProxy);

  • dominik.urban
    dominik.urban Posts: 9
    edited October 26

    Achillemonga is right. With "http-proxy-middleware" it is pretty straight forward.
    Change the URL in the example given at https://www.npmjs.com/package/http-proxy-middleware and you are good to go! :)

    spoilers ...
    const express = require("express");
    const { createProxyMiddleware } = require("http-proxy-middleware");
    const app = express();
        target: "https://jsonplaceholder.typicode.com",
        changeOrigin: true,

  • elegant solution :+1:

  • nayib
    nayib Posts: 12

    @achillemonga and @dominik.urban thanks, yes, I normally use http-proxy-middleware package. Thanks for the response.

This discussion has been closed.


Upcoming Training