Skip to content

Instantly share code, notes, and snippets.

@slawekzachcial
Created June 25, 2019 20:42
Show Gist options
  • Save slawekzachcial/feadc5e4bab9b05661398e2b732c5155 to your computer and use it in GitHub Desktop.
Save slawekzachcial/feadc5e4bab9b05661398e2b732c5155 to your computer and use it in GitHub Desktop.
http-proxy-middleware proxy by path, including websockets
const express = require('express')
const proxy = require('http-proxy-middleware')
const app = express()
app.use('/xxx', proxy('/xxx', {
target: 'http://localhost:8443',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/xxx': ''
}
}))
app.use('/yyy', proxy('/yyy', {
target: 'http://localhost:9443',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/yyy': ''
}
}))
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment