1.0.1 • Published 9 years ago

express-reproxy v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

reproxy

Simple utility, intended for proxying requests to remote services if CORS is not available for some reason. Usually this is useful for development environments.

Install with npm install hogart/reproxy -s. Requires recent nodejs version (4.x should work).

Usage

const app = express();
require('reproxy')(app, [[/\someEndpoint\/(.*)/, 'http://real-endpoint/api/$1']]);

Config

Config looks like following:

[
    [/\someEndpoint\/(.*)/, 'http://real-endpoint/api/$1'], // regexp and replacement string
    [/\\otherEndpoint\/(.*)/, (match, group1) => { return 'http://other-endpoint/' + group1.split('/').reverse().join('/'); }], // regexp and replacement function
    ['/simpleString/', 'http://example.com'] // request will be made to `'http://example.com' + '/simpleString/'`;
]