ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.69k stars 187 forks source link

Local mapping without an active internet connection #2092

Open m-mattia-m opened 4 months ago

m-mattia-m commented 4 months ago

Description

I'm using a external JS and CSS file for my frontend which I can't change. Now I downloaded these two file and mapped the request to this files. The files are correct but if I work offline the local file mapping doesn't work. Do I need an active internet connection for a local proxy that is in charge of the mapping?

NghiaTranUIT commented 4 months ago

Do I need an active internet connection for a local proxy that is in charge of the mapping?

It should work if it's a Map Local tool because it's a MOCK Response. It doesn't make a real connection to the server, so the Internet Connection is not needed.

Now I downloaded these two file and mapped the request to this files.

Can you show me how your Map Local setting is?

m-mattia-m commented 4 months ago

Thank you for your quick response. :)

I have this two rules:

# Stoplight - JS

GET
https://unpkg.com/@stoplight/elements@8.1.0/web-components.min.js
Use Wildcard
Include all subpaths of this URL

<import-file: web-components-min-js.txt>

# Stoplight - CSS

GET
https://unpkg.com/@stoplight/elements@8.1.0/styles.min.css
Use Wildcard
Include all subpaths of this URL

<import-file: styles-min-css.txt>

Files as gists

NghiaTranUIT commented 4 months ago

I guess when you import the file <import-file: web-components-min-js.txt>, it removes all Status Code and Response Header, right?

So, maybe your client will reject this request because there is no Content-Type header.

I suggest.

  1. Disable your rules first
  2. Make a request to https://unpkg.com/@stoplight/elements@8.1.0/web-components.min.js by Google Chrome -> If it's Cached -> Go to Tool -> No Caching Tool -> Resent the request again
  3. Verify we can see the JS Response of your URL in the main app
  4. Right Click on the request -> Tools -> Map Local -> Done
  5. Try again to make sure Map LOcal works
  6. Turn off the Wi-Fi and try again

I tested by using cURL and it works fine 👍

m-mattia-m commented 4 months ago

Yes you're right there isn't any HTTP Status Code it's only (failed) net::ERR_INTERNET_DISCONNECTED.

I deleted my local mapping rules and recreated them as you've described. However if I disable my Wi-Fi I'm still getting this error: (failed) net::ERR_INTERNET_DISCONNECTED.

Proxyman (v5.6.1) is active. Proxy Helper Tools (v1.6.0) is installed and active. There aren't any other active VPNs or Proxies.

NghiaTranUIT commented 4 months ago

@m-mattia-m can you use cURL to test it?

  1. Set up the Map Local from my instruction
  2. curl https://unpkg.com/@stoplight/elements@8.1.0/web-components.min.js --proxy localhost:9090 -> Verify we can see the Response from Map Local (There is a tick on the Edited Column on the main table -> It means the Map Local is applied)
  3. Turn off your wifi
  4. Run the curl again -> Verify we can see the response

If it's good, but your Google Chrome doesn't work, I guess the Google Chrome has a feature to check the Internet connection before making any requests. If there is no internet, it's failed immediately without calling to Proxyman.

m-mattia-m commented 4 months ago

@NghiaTranUIT

I tested it now with cURL, which works even without an internet connection (it has the tick in the "Edited" column, and I got my response). However, as soon as I tried it in Google Chrome (Arc), it didn't work. When I use my browser, I always get the above error. I also tested it with http://proxyman.local:8081 but it had the same result.

Do you know any solution for this problem that it doesn't work in Chrome (I also tested it with Firefox and Safari, and it doesn't work either)?

NghiaTranUIT commented 4 months ago

I see: If the Wi-Fi is OFF, Google Chrome or Safari won't use the Proxy anymore because the Proxy Setting is applied to the Wi-Fi. As a result, no internet connection on Google Chrome, but works with cURL.

To workaround it, you should use Firefox:

  1. Open Firefox -> Setting -> Search "Proxy" -> Select Manual Proxy Config -> Set HTTP Proxy and HTTPS Proxy with IP = 127.0.0.1 at port 9090
  2. Follow this guide to install & trust Proxyman certificate to Firefox: https://docs.proxyman.io/debug-devices/firefox
  3. Setup the Map Local rule by following my previous instruction
  4. Done

https://github.com/user-attachments/assets/25e700b6-8daa-4ccf-856c-eff4b0856ccf


By using Manual Proxy in Firefox, it will work regardless of the Wi-Fi connection.

m-mattia-m commented 4 months ago

It works fine in Firefox. I think it's a missing feature of Chrome, but if there's a way that Proxyman could solve the missing proxy problem in Chrome it would be great.

NghiaTranUIT commented 4 months ago

Sorry, Proxyman can't fix this problem from Google Chrome because Google Chrome doesn't offer a way to set a manual proxy. It use the system proxy by default.

Only Firefox or Firefox-based web browsers like Brave have this feature.

m-mattia-m commented 4 months ago

For everyone who is coming across this thread, I've found a Chrome extension for this problem. If you search for "Proxy" in the Chrome extension store, you are going to find many options that are working. One of these is Proxy SwitchyOmega .

After you have added this extension to your browser, you can open "options" and configure Proxyman as your proxy (localhost:9090). (Don't forget to click the "Apply changes" button on the left side.) After that, you can switch between the profiles (system or proxy).

switchy-omega-proxy
NghiaTranUIT commented 4 months ago

Thanks, this Google Proxy extension will work. Let me know if you have any problems 👍