reverse proxy using expressjs
var express = require('express');
var app = express();
var httpProxy = require('http-proxy');
var apiProxy = httpProxy.createProxyServer();
var serverOne = 'http://localhost:3001',
ServerTwo = 'http://localhost:3002',
ServerThree = 'http://localhost:3002';
app.all("/app1/*", function(req, res) {
console.log('redirecting to Server1');
apiProxy.web(req, res, {target: serverOne});
});
app.all("/app2/*", function(req, res) {
console.log('redirecting to Server2');
apiProxy.web(req, res, {target: ServerTwo});
});
app.all("/app2/*", function(req, res) {
console.log('redirecting to Server3');
apiProxy.web(req, res, {target: ServerThree});
});
app.listen(3000);
Also in JavaScript:
- how to clear array in javascript
- take a screen shot of a image within a div using js
- creating a nested loop of a chessboard in javascript
- select a form by name jquery
- javascript print int with leading zeros
- server info discord.js
- Unexpected end of JSON input while parsing near '...fcd15e632426a1be","ta'
- how to redirect to another page in javascript on submit type
- download comma separated file, react
- The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object. scoop
- javascript get last element of array
- routes in node js
- jquery disable keypress
- render react in blaze
- allow cross origin node
- new Map() collection in react state
- nested array loop in javascript
- shadow elevation react native
- how to calculate the number of days between two dates in javascript
- mocha js
- preventive vs reactive
- json placholder
- javascript create checkbox with label
- jquery duplicate last table row