UNPKG

forwarded-host

Version:

Determine the host of the originating request

29 lines (18 loc) 719 B
# 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: ```js '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.