Skip to content

[BUG] Query parameters in target are not passed when proxying #16

@KrammyGod

Description

@KrammyGod

When the target has query params AND ignorePath option is set, they are completely omitted when the server actually proxies the request. In http-proxy, the query parameters are still sent, just the actual request's path is not added.

Steps to Reproduce

Start with a simple server on port 8081 logging the url:

import { createServer } from 'http';

const server = createServer((req, res) => {
  console.log(req.url);
  res.end('OK');
});
server.listen(8081);

Then, create a proxy server on port 8080, to receive the request, and proxy to the server on port 8081:

import { createServer } from 'http';
import { createProxyServer } from 'http-proxy-3';

const proxyServer = createProxyServer({
  target: 'http://localhost:8081/test?query=test',
  ignorePath: true,
});

const server = createServer((req, res) => {
  proxyServer.web(req, res);
});
server.listen(8080);

With http-proxy-3, the server on port 8081 outputs: /test, whereas with http-proxy (and http-proxy-node16), the server outputs /test?query=test. Interestingly enough, this bug also exists in httpxy.

Note that without ignorePath: true, the query params pass through fine. Let me know if this is actually intended behaviour, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions