Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript
branch: master
Failed to load latest commit information.
example inital commit
test inital commit
.gitignore inital commit
.travis.yml added travis configuration file
README.md simplify example
index.js inital commit
package.json changed version number

README.md

node-inject

A middleware component for node-http-proxy to inject a script file to all served html files.

build status

install

$ npm install node-inject

example

The following example will inject a script to the nodejs website through a proxy running on http://localhost:8000.

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

httpProxy.createServer(
    require('node-inject')("https://raw.github.com/btotr/node-inject/master/example/inject.js"),
    function (req,res,proxy) {
        proxy.proxyRequest(req, res, {
          host: 'nodejs.org',
          port: 80
        });
    }
).listen(process.env.PORT || 8000);

To run this example you will need http-proxy 0.8.7 as-well.

$ npm install http-proxy@0.8.7
Something went wrong with that request. Please try again.