-
Notifications
You must be signed in to change notification settings - Fork 821
/
index.js
29 lines (23 loc) · 751 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Module dependencies.
*/
const http = require('http');
const connect = require('connect');
const { createProxyMiddleware } = require('../../dist'); // require('http-proxy-middleware');
/**
* Configure proxy middleware
*/
const jsonPlaceholderProxy = createProxyMiddleware({
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
});
const app = connect();
/**
* Add the proxy to connect
*/
app.use('/users', jsonPlaceholderProxy);
http.createServer(app).listen(3000);
console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000/users');
require('open')('http://localhost:3000/users');