JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 539593
  • Score
    100M100P100Q178593F
  • License BSD

http(s) proxy as connect middleware

Package Exports

  • proxy-middleware

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (proxy-middleware) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

Usage:

var connect = require('connect')
  , url = require('url')
  , proxy = require('proxy-middleware')

var app = connect();
app.use('/api', proxy(url.parse('https://example.com/endpoint')));
// now requests to '/api/x/y/z' are proxied to 'https://example.com/endpoint/x/y/z'

Documentation:

proxyMiddleware(options)

options allows any options that are permitted on the http or https request options.

Other options:

  • route: you can pass the route for connect middleware within the options, as well.
  • via: by default no via header is added. If you pass true for this option the local hostname will be used for the via header. You can also pass a string for this option in which case that will be used for the via header.

Usage with route:

var proxyOptions = url.parse('https://example.com/endpoint');
proxyOptions.route = '/api';

var middleWares = [proxy(proxyOptions) /*, ...*/];

// Grunt connect uses this method
connect(middleWares);