node-proxy-middleware icon indicating copy to clipboard operation
node-proxy-middleware copied to clipboard

/endpoint gets proxied to /endpoint/

Open 0xR opened this issue 9 years ago • 9 comments

I have an endpoint /endpoint which I want to proxy to, however all my requests get redirected to /endpoint/ which doesn't exist.

It is set up like so: app.use('/endpoint', proxy('http://somehost.com/endpoint'));

The error seems to be somewhere in slashJoin in index.js.

0xR avatar Sep 07 '15 07:09 0xR

Running into this issue as well. @0xR you have a PR lined up? If not I'll see if I can make the change. @andrewrk what are your thoughts on this?

jlank avatar Oct 23 '15 18:10 jlank

My thoughts:

I don't write code for this module any more. I'm pretty sure the first version I released didn't have this problem. I just merge pull requests if the tests pass and cut releases. It's an experiment in a community maintained module.

andrewrk avatar Oct 23 '15 20:10 andrewrk

my PR broke the tests; working on fixing that now. I'll let you know when they're up to snuff, thanks!

jlank avatar Oct 23 '15 20:10 jlank

this issue can be closed, fix landed in v0.15.0 d3f462e23d4dda4483fac601649bec33735548f1

jlank avatar Oct 24 '15 01:10 jlank

jeez, feel stupid here, but when I fixed the tests I somehow reverted my fix ... :-1:

let's keep this open, sending another PR - its been a long week!

jlank avatar Oct 24 '15 01:10 jlank

Thanks for making a fix. Instead of spending time making a PR I just switched to express-http-proxy. Good luck on recreating the fix though haha.

0xR avatar Oct 24 '15 10:10 0xR

We are experiencing the same issue. This module is used in ionic and our proxies pointing to /endpoint are redirecting to /endpoint/ causing an issue. Are there any other workarounds?

koga73 avatar Nov 02 '15 22:11 koga73

@koga73 I know it's late, but there is a workaround using the route option:

var url = require('url');
var options = url.parse('http://www.website.com');
options.pathname = '/endpoint';
options.route = '/api/endpoint';
app.use(proxy(options));
// redirect /api/endpoint to http://www.website.com/endpoint

This is possible thanks to the url rewriting made with this route option.

Pyo25 avatar Jul 12 '16 15:07 Pyo25

@Pyo25 i think it's not the same question

app.use('/api/endpoint', proxy('http://somehost.com/endpoint'));

i'm facing the problem,when app.use('/sampath', proxy('http://somehost.com/sampath')); it goes into Error: connect ENOBUFS 10.10.1.183:9527 - Local (undefined:undefined)

WLyKan avatar Dec 22 '16 08:12 WLyKan