Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. var express = require('express');
  2. var app = express();
  3. var httpProxy = require('http-proxy');
  4. var apiProxy = httpProxy.createProxyServer();
  5. var backend = 'http://localhost:8080',
  6. frontend = 'http://localhost:3001';
  7.  
  8. app.all("/rest/*", function(req, res) {
  9. apiProxy.web(req, res, {target: backend});
  10. });
  11.  
  12. app.all("/*", function(req, res) {
  13. apiProxy.web(req, res, {target: frontend});
  14. });
  15.  
  16. var server = require('http').createServer(app);
  17. server.on('upgrade', function (req, socket, head) {
  18. apiProxy.ws(req, socket, head, {target: frontend});
  19. });
  20. server.listen(3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement