Skip to content

Instantly share code, notes, and snippets.

@BeerOnBeard
Created September 26, 2017 13:02
Show Gist options
  • Save BeerOnBeard/2cea57a36d5438cb354663cfae5fe83b to your computer and use it in GitHub Desktop.
Save BeerOnBeard/2cea57a36d5438cb354663cfae5fe83b to your computer and use it in GitHub Desktop.
FiddlerScript for HTTPS Proxy to Localhost Application
// 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