Skip to content

Instantly share code, notes, and snippets.

@acorcutt
Created January 5, 2011 17:59
Show Gist options
  • Save acorcutt/766693 to your computer and use it in GitHub Desktop.
Save acorcutt/766693 to your computer and use it in GitHub Desktop.
This makes testing with domains and sub-domains easier on a mac, choose "Automatic Proxy Configuration" in Airport settings and set the URL to this file. Then any request to port 3000 will be pointed to the local rails server e.g. http://sub.mydomain.c
function FindProxyForURL(url, host) {
var port = url.match(/^\w{3,5}:\/\/[^:\/]*(:(\d+))?/)[2];
if(port){
if(port=="3000"){
var proxy = "PROXY localhost";
if(port){proxy += ":" + port;}
return proxy;
}
}
return "DIRECT";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment