forwarded-host

Determine the host of the originating request


Keywords
x-forwarded-host, proxy, node, forward, host
License
MIT
Install
npm install forwarded-host@0.0.4

Documentation

forwarded-host

Determine the URL of the originating request using x-forwarded-host, x-forwarded-port and x-forwarded-proto. Ideal if you are running a service behind a proxy and want to serve up absolute URLs in your response payload.

Installation

The module is released in the npm registry:

npm install --save forwarded-host

Getting started

Include the module in to your application:

'use strict';

var forwarded = require('forwarded-host');

require('http').createServer(function (req, res) {
  var url = forwarded(req);

  res.end('Your url is '+ url);
}).listen(8080);

Run the service behind a proxy and as long as X-Forwarded-Host is sent in the header, the URL should be correct.