Skip to content

Conversation

@dometto
Copy link
Contributor

@dometto dometto commented Dec 2, 2025

While testing the implementation of #592 a bit more thoroughly in combination with JupyterHub, I noticed two issues:

  • the errorTarget option was not working correctly with unix socket
  • URI's with subpaths were not working correctly with unix sockets -- requests for /foo were being transformed into /foo/foo.

Error target not working correctly

Was seeing invalid url errors because unix socket paths, e.g. %2Ftmp%2Ftest.sock, was being passed as a URL. Added logic to rewrite the hostname to localhost . I also added a test of the errorTarget functionality with unix sockets.

URLs with subpaths

I traced the issue to this line in the http-proxy library.

Basically, target in this library's proxyOptsForTarget function already contains path info. By also setting target.pathname in proxyOptsForTarget, the result is that the existing path and pathname are joined together by http-proxy.

The fix is to remove the additional setting of target.pathname in proxyOptsForTarget. This also means we can refactor proxyOptsForTarget to not require the reqUrl argument.

I've modified the existing test with unix socket to use a subpath.

- no need to add request's url to the request path. This already exists and leads to duplication.
- fix custom error routes with unix socket by setting target hostname to localhost.
Copy link
Member

@minrk minrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than one question about changing the logging config in tests, looks great, thank you!

options = options || {};
options.authToken = "secret";
options.log = defaultLogger({ level: "error" });
//options.log = defaultLogger({ level: "error" });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be restored? Or was there a reason it was removed/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants