Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong path when using HTTP proxy in Node API http #27692

Closed
Young-Lord opened this issue Jan 16, 2025 · 0 comments · Fixed by #27871
Closed

Wrong path when using HTTP proxy in Node API http #27692

Young-Lord opened this issue Jan 16, 2025 · 0 comments · Fixed by #27871
Assignees

Comments

@Young-Lord
Copy link

Young-Lord commented Jan 16, 2025

Version: Deno 2.1.5

TLDR: when http.request's opinions include proxy settings and options.path is a full URL (e.g., http://httpbin.org/200), the website that proxy server accesses should be http://httpbin.org/200, but in Deno it is http://httpbin.org/http://httpbin.org/200.

POC:

import axios from "axios";
const instance = axios.create({
  baseURL: "http://httpbin.org/",
  proxy: {
    protocol: "http",
    host: "127.0.0.1",
    port: 8892,
  },
});
try {
  const resp = await instance.get("/get");
  console.log("success", resp.config);
} catch (e) {
  console.log(e);
}

For convenience, I use Axios as demo, and related code is here. When I add a patch options.path = new URL(options.path).pathname;, it becomes correct.
This demo requires a http proxy running at port 8892 (such as Fiddler or mitmproxy).

In Node.JS, it can get http://httpbin.org/get correctly. In Deno, it gets a 404, while Fiddler shows it is requesting http://httpbin.org/http://httpbin.org/get

@Young-Lord Young-Lord changed the title inconsistent HTTP proxy in Node API http Wrong path when using HTTP proxy in Node API http Jan 16, 2025
@kt3k kt3k self-assigned this Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants