How to redirect unpkg.com to unpkg.zhimg.com?

2 Answers 114 Views
Fiddler Classic
chen
Top achievements
Rank 2
Bronze
Iron
Iron
chen asked on 16 Dec 2023, 04:11 AM

In my network environment, I cannot access unpkg.com, which causes some of my web pages to load improperly. I can access unpkg.zhimg.com, which can replace unpkg.com. Therefore, I'm wondering if I can use Fiddler to replace all accesses to unpkg.com with accesses to unpkg.zhimg.com. To do this, I used the following code in FiddlerScript:


if (oSession.HTTPMethodIs("CONNECT") && (oSession.PathAndQuery == "unpkg.com:443")) { 
          oSession.PathAndQuery = "unpkg.zhimg.com:443"; 
}

if (oSession.HostnameIs("unpkg.com")) oSession.hostname = "unpkg.zhimg.com";

When I try to access unpkg.com, I encounter the following error:

"fiddler.network.https> HTTPS handshake to unpkg.com (for #2) failed. System.Security.Authentication.AuthenticationException."

From the error message, it seems like Fiddler is still attempting to establish a connection with unpkg.com before accessing unpkg.zhimg.com. Is it possible to configure Fiddler to directly access unpkg.zhimg.com without attempting to connect to unpkg.com first?

2 Answers, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 18 Dec 2023, 09:09 AM

Hi Chen,

 

Ensure that your FiddlerScript code is executed before the actual request is sent, for example, in the OnBeforeRequest event. This way, Fiddler will modify the request before it is sent to the server and the TLS handshake should be made with the modified endpoint.

As a side note, you should be able to achieve the redirect through the AutoResponder as discussed in this forum thread or this SO thread.

 

Regards,
Nick Iliev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
chen
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 19 Dec 2023, 01:42 AM
Thank you for your reply. I have achieved the functionality I need using the redirect extension in Chrome. I will also try to achieve the required functionality using Fiddler later.
Tags
Fiddler Classic
Asked by
chen
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Nick Iliev
Telerik team
chen
Top achievements
Rank 2
Bronze
Iron
Iron
Share this question
or