Search code examples
ruby-on-railsruby-on-rails-4webrick

Access localhost:3000 through mysite.loc


When I'm on my development laptop, I want to go to the URL "mysite.loc" instead of "localhost:3000" for a particular project. How can I do this?

I am using Ruby on Rails 4, and the default WEBrick server.

I have tried adding "127.0.0.1 mysite.loc" to my /etc/hosts file.


Solution

  • Some people suggest installing Fiddler

    Add your local sitename to the HOSTS file then add a custom rule to Fiddler.

    static function OnBeforeRequest(oSession: Session) {  
      if (oSession.host.toLowerCase() == "mysite.loc") { 
        oSession.host = "mysite.loc:3000";
      }
    }
    

    Then when you navigate to http://mysite.loc it should be proxied to http://mysite.loc:3000.

    Related questions: ServerFault StackOverflow