forwarded-host

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i forwarded-host

Weekly Downloads

10

Version

1.0.0

License

MIT

Last publish

Collaborators

  • p3tecracknell