-
Notifications
You must be signed in to change notification settings - Fork 865
/
Copy pathindex.js
33 lines (29 loc) · 851 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
30
31
32
33
/**
* Module dependencies.
*/
const browserSync = require('browser-sync').create();
const { createProxyMiddleware } = require('../../dist'); // require('http-proxy-middleware');
/**
* Configure proxy middleware
*/
const jsonPlaceholderProxy = createProxyMiddleware({
target: 'http://jsonplaceholder.typicode.com',
pathFilter: '/users',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logger: console,
});
/**
* Add the proxy to browser-sync
*/
browserSync.init({
server: {
baseDir: './',
port: 3000,
middleware: [jsonPlaceholderProxy],
},
startPath: '/users',
});
console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000/users');
process.on('SIGINT', () => browserSync.exit());
process.on('SIGTERM', () => browserSync.exit());