map localhost to remote

5 posts, 1 answers
  1. harilal
    harilal avatar
    3 posts
    Member since:
    Jun 2015

    Posted 24 Jun 2015 Link to this post

    I am working in a ui project which had a dataservice in a public server. I need to redirect the service calls only to remote . like

    http://localhost/project/service/user to http://192.168.3.250:8080/project/service/user

    http://localhost/project/service/edit to http://192.168.3.250:8080/project/service/edit

    I need to replace the part of the uri and get the response from the remote server. 

     

  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 25 Jun 2015 Link to this post

    Hello,

    I assume that the service in question is using HTTP or HTTPS, right?

    The simplest way to do this is to click Tools > HOSTS.... Click the Checkbox and add a line to the box below:

        192.168.3.250:8080 localhost


    Note: if you don't see requests to "localhost" in Fiddler at all, the client is probably using .NET which bypasses the proxy for the "localhost" hostname. You'll need to follow these steps: http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/MonitorLocalTraffic


    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. harilal
    harilal avatar
    3 posts
    Member since:
    Jun 2015

    Posted 25 Jun 2015 in reply to Eric Lawrence Link to this post

    actually i don't need to route all request from local host. only service calls like http://localhost/project/service/* . Am using XAMPP and only http connection.
  4. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 26 Jun 2015 Link to this post

    Hi, Harilal--

    If you need to redirect only some requests from one host to another, you should use script for that instead. First, disable anything you did inside Tools > HOSTS. Then, click Rules > Customize Rules. Scroll to the OnBeforeRequest method and inside it add the following code:


       if (oSession.HostnameIs("localhost") &&
           oSession.uriContains("/project/service/"))
       {
          oSession["X-OverrideHost"] = "192.168.3.250:8080";
       }


    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. harilal
    harilal avatar
    3 posts
    Member since:
    Jun 2015

    Posted 28 Jun 2015 in reply to Eric Lawrence Link to this post

    Thanks Eric it worked .. I have been working on this issue for one week :)
Back to Top