Proxyman icon indicating copy to clipboard operation
Proxyman copied to clipboard

Wrong target host is used although raw HTTP request shows the right target host

Open ChristianWeyer opened this issue 2 years ago • 12 comments

Description

This is really strange.

I am using Proxyman on macOS all the time without any issues. Now, I have a node.js app that uses axios to talk to OpenAI API and Spotify API.

I get a 403 on a request that should go to Spotify but actually goes to OpenAI, using the token meant for Spotify. Obviously, OpenAI gives me a 403.

image

If I disable proxying for the node.js app, everything works fine. If I use Charles proxy, everything works fine.

I am lost... ;-)

Environment

  • App version: e.g Proxyman 4.11.0
  • macOS version: Ventura 13.5.2

ChristianWeyer avatar Sep 21 '23 20:09 ChristianWeyer

@ChristianWeyer do you use any Debugging Tools that modify the Request Header?

By default, Proxyman doesn't change any Request/Response data, each request is a separate tunnel, so it doesn't affect to other requests/responses. It means that the Host: api.spotify.com issue is likely from the client side, not Proxyman.

Can you double-check it on your side?

NghiaTranUIT avatar Sep 22 '23 01:09 NghiaTranUIT

Hi @NghiaTranUIT - nope, I am going straight from the TypeScript/JS code via Proxyman to the target URLs. It works with other debugging proxy tools. This is why I am so confused...

ChristianWeyer avatar Sep 22 '23 05:09 ChristianWeyer

FYI: this is the code I am using in this case: https://github.com/microsoft/TypeChat/tree/main/examples/music

ChristianWeyer avatar Sep 22 '23 05:09 ChristianWeyer

E.g., this is a line in the code that seems to fail (according to the screenshot above): https://github.com/microsoft/TypeChat/blob/ec3a37c44168ff5d3fef954a62278e205a3bab4f/examples/music/src/endpoints.ts#L445

ChristianWeyer avatar Sep 22 '23 05:09 ChristianWeyer

I have a similar issue. Different hosts switching.
When I quit proxyman, things work fine. This is very frustrating.

mattruby avatar Dec 28 '23 04:12 mattruby

It's odd. Let's me investigate it 👍

NghiaTranUIT avatar Dec 29 '23 02:12 NghiaTranUIT

@mattruby do you use any debugging tool that might change the host? (such as Map Remote, Breakpoint or Scripting)

By default, Proxyman doesn't change the host, and Proxyman makes a connection by the Host Header, so I'm not sure why it can happen 🤔

NghiaTranUIT avatar Dec 29 '23 05:12 NghiaTranUIT

I have PIA with a dedicated IP in the mix. It really makes no sense. I'm happy to hop on a screen share and show you what's happening. I've tried resetting everything in proxyman.

I'm using axios in a nest.js app. I'm pointing it at the proxy using this: export https_proxy=http://192.168.68.126:9090 http_proxy=http://192.168.68.126:9090

This is the correct endpoint being proxied and called: CleanShot 2023-12-29 at 10 22 48@2x

For some reason, those introspect calls seem to leak into the cart service: CleanShot 2023-12-29 at 10 25 36@2x

With export NODE_DEBUG=http,http I can see that I'm trying to call the correct endpoint: CleanShot 2023-12-29 at 10 34 58@2x

mattruby avatar Dec 29 '23 16:12 mattruby

Is there a way for me to send you a debug log or anything? I'm happy to do so. ProxyMan has saved me so much time!

mattruby avatar Dec 29 '23 17:12 mattruby

I wonder if axios is the problem? https://github.com/axios/axios/issues/5725 looks like it's worth looking into.

mattruby avatar Feb 19 '24 18:02 mattruby

Here's another interesting axios proxy issue: https://github.com/axios/axios/pull/3159 When I set the env params to what proxyman provides: export https_proxy=http://192.168.68.128:9090 http_proxy=http://192.168.68.128:9090 both entries are http.

mattruby avatar Feb 19 '24 19:02 mattruby

@mattruby I believe that it's from Axios because there are some people has encountered issue on Axios too.

From what I see on your screenshot, you don't have any debugging tool, so Proxyman won't modify your URL.

NghiaTranUIT avatar Feb 20 '24 01:02 NghiaTranUIT