Created
September 26, 2017 13:02
-
-
Save BeerOnBeard/2cea57a36d5438cb354663cfae5fe83b to your computer and use it in GitHub Desktop.
FiddlerScript for HTTPS Proxy to Localhost Application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I use this to hijack AJAX requests to subdomains of the site that rely on CORS to function. I want the host | |
// names to look like they are from the same host but swap out a local server for testing. | |
// Add this if-statement to the OnBeforeRequest method. It ignores CONNECT methods to allow HTTPS handshake. | |
// All other requests will be redirected to localhost over HTTP. | |
if (!oSession.HTTPMethodIs("CONNECT") && oSession.HostnameIs("my.public.site.com")) | |
{ | |
oSession.host = "localhost:10010" | |
oSession.oRequest.headers.UriScheme = "http"; | |
} | |
// Add this if-statement to the OnBeforeResponse method. For any responses from the localhost server we swap | |
// out the host value for the expected host value so the browser thinks all is well. | |
if (oSession.host.Equals("localhost:10010")) | |
{ | |
oSession.host = "my.public.site.com:443"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment