Skip to content

Instantly share code, notes, and snippets.

@configurator
Created March 23, 2020 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save configurator/c8e368926aa4abd7d0317fa1c53ba597 to your computer and use it in GitHub Desktop.
Save configurator/c8e368926aa4abd7d0317fa1c53ba597 to your computer and use it in GitHub Desktop.
A basic reverse proxy in node.js
// This reverse proxy is for local development only
const express = require("express");
const proxy = require("express-http-proxy");
const app = express();
const proxyPort = 8000;
const webpackPort = 8080;
app.use("/", proxy(`http://localhost:${webpackPort}`));
app.listen(proxyPort, () =>
console.log(
`Proxying http://localhost:${proxyPort}/ => http://localhost:${webpackPort}/`
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment