use( "/api", createProxyMiddleware({ target: false ? "http://localhost:8080" : "https://speechifai-poc.herokuapp.com", changeOrigin: true, pathRewrite: { "^/api": "/", // rewrite path }, }) ); }; I have: "http-proxy-middleware": "^2.0.3", And I call here with axios...
const{createProxyMiddleware}=require('http-proxy-middleware');constrewriteFn=function(path,req){returnpath.replace('/api/foo','/api/bar');};constoptions={target:'http://localhost:3000',pathRewrite:rewriteFn,};constapiProxy=createProxyMiddleware(options);// `/api/foo/lorum/ipsum` -> `http:...
Create and configure a proxy middleware with:createProxyMiddleware(config). const{createProxyMiddleware}=require('http-proxy-middleware');constapiProxy=createProxyMiddleware({target:'http://www.example.org',changeOrigin:true,});// 'apiProxy' is now ready to be used as middleware in a server. o...
method === 'GET'; }; const apiProxy = createProxyMiddleware({ target: 'http://www.example.org', pathFilter: pathFilter, });pathRewrite (object/function)Rewrite target's url path. Object-keys will be used as RegExp to match paths....