x-forwarded-from-hapi

Get the correct x-forwarded-* headers, as implemented by h2o2

Usage no npm install needed!

<script type="module">
  import xForwardedFromHapi from 'https://cdn.skypack.dev/x-forwarded-from-hapi';
</script>

README

x-forwarded-from-hapi

A simple module that mimics the way that h2o2 sets x-forwarded headers, for when you need to implement your own pseduo-proxy route but want to be a good forwarding citizen.

Usage

import xForwardedFromHapi from 'x-forwarded-from-hapi';

//...

server.route({
  path: '/proxy',
  handler(req, reply) {
    //...
    Wreck.request('GET', 'http://target.server/someUri', {
      payload: req.payload,
      headers: {
        ...req.headers,
        ...xForwardedFromHapi(req),
      }
    }, reply);
  },
});