question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to ignore proxy path prefix

See original GitHub issue

Hi,

I need to proxy requests from /api to the root of other site: http://test.com:

/api/users -> http://test.com/users /api/users/1 -> http://test.com/users/1

But all my requests lead to http://test.com/api/* How to ignore /api prefix but not to ignore other path? When I use ignorePath settings all my requests lead to http://test.com.

Config:

server.middleware = proxyMiddleware('/api', {target: 'http://test.com', proxyHost: 'test.com'});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

24reactions
chimuraicommented, Sep 28, 2015

Ah, didn’t read your question well… 😃

You can rewrite paths with the pathRewrite option. https://www.npmjs.com/package/http-proxy-middleware#options

var options = {
  target: 'http://test.com',
  changeOrigin: true,
  pathRewrite: {'^/api' : ''}      // <-- this will remove the /api prefix
};

server.middleware = proxyMiddleware('/api', options);
11reactions
thatisudaycommented, Feb 28, 2018

Can we add a boolean option to plainly avoid path prefixing. pathRewrite still sound complex.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NGINX proxy_pass remove path prefix & resolve DNS
Essentially all I want to achieve here is to proxy a request while removing the path prefix in such a way that DNS...
Read more >
We need to talk: Can we standardize NO_PROXY? - GitLab
You may be less familiar with no_proxy , which provides a way to exclude traffic destined to certain hosts from using the proxy....
Read more >
Set up a proxy integration with a proxy resource - Amazon API ...
To set up a proxy integration in an API Gateway API with a proxy resource, you perform the following tasks: Create a proxy...
Read more >
http-proxy-middleware - npm
Start using http-proxy-middleware in your project by running `npm i ... specify whether you want to ignore the proxy path of the incoming ......
Read more >
Proxy support in Chrome
Specifying an HTTPS proxy is generally not possible through system proxy settings. Instead, one must use either a PAC script or a Chrome...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found