Tomasz Adamiak
Tomasz Adamiak

Reputation: 15

Node JS http-proxy - issue with created URL

I created simple proxy server in node JS, it looks like this:

var httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer({});

//proxy config
app.all('/proxy/*', function (request, response) {
    "use strict";
    return proxy.web(request, response, {
    target: 'http://localhost:1234/'
    });
});

The problem I'm having is that it creates proxy URL from lets say sample request:

$http.get('/proxy/example')
        .success( function(res) {
          $scope.quote = res;
          alert($scope.quote);
          })

which looks like this:

localhost:1234/proxy/example

but I want it to create URL lookin like this:

localhost:1234/example

What am I doing wrong?

PS Sorry if question is not formatted properly or too easy - it's my first ask on stack

Upvotes: 0

Views: 69

Answers (1)

Node
Node

Reputation: 86

Don't do /proxy/example instead write only example

   $http.get('example')
    .success( function(res) {
      $scope.quote = res;
      alert($scope.quote);
      })

Upvotes: 1

Related Questions