Created
June 25, 2019 20:42
-
-
Save slawekzachcial/feadc5e4bab9b05661398e2b732c5155 to your computer and use it in GitHub Desktop.
http-proxy-middleware proxy by path, including websockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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