0

I am trying to setup http-proxy-middleware for multiple API URLs with same end point, which is not working.

setupProxy.php

const proxy =require("http-proxy-middleware");

module.exports = function(app)
{
  app.use(proxy("rest/V1/orders",{target:"http://example.net/",changeOrigin:true}));
  app.use(proxy("rest/V1/orders",{target:"http://example.org/",changeOrigin:true}));
  app.use(proxy("rest/V1/orders",{target:"http://example.com/",changeOrigin:true}));
}
James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

use this package for https-proxy-middleware

For setup Create setupProxy.js under src directory

Ref the doc for sample code

ChandraKumar
  • 515
  • 4
  • 14
  • Hi iam using https-proxy-middleware package only My issue is for multiple API URLs with same endpoint, not working as expected please suggest, PFA code in setupProxy.php – T Bharathiraj Apr 30 '20 at 23:18
  • Multiple API URLs with same endpoints means `https://ex.com/test` and `https://ex1.com/test` like these... As I can't write an entier code in a comment I could edit my answer based on your need – ChandraKumar May 01 '20 at 08:26
  • Multiple API URLs with same endpoints means https://ex.com/test and https://ex1.com/test like these. correct, I need the same. please suggest on this. – T Bharathiraj May 02 '20 at 18:52
  • If you are fetching like this who do you need a proxy in the first place you could directly call the endpoints from the client right – ChandraKumar May 03 '20 at 17:56