UNPKG

676 BJavaScriptView Raw
1/**
2 * Module dependencies.
3 */
4var express = require('express');
5var proxy = require('../../index'); // require('http-proxy-middleware');
6
7/**
8 * Configure proxy middleware
9 */
10var jsonPlaceholderProxy = proxy({
11 target: 'http://jsonplaceholder.typicode.com',
12 changeOrigin: true, // for vhosted sites, changes host header to match to target's host
13 logLevel: 'debug'
14});
15
16var app = express();
17
18/**
19 * Add the proxy to express
20 */
21app.use('/users', jsonPlaceholderProxy);
22
23app.listen(3000);
24
25console.log('[DEMO] Server: listening on port 3000');
26console.log('[DEMO] Opening: http://localhost:3000/users');
27
28require('opn')('http://localhost:3000/users');