-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproxy-mock.conf.js
50 lines (41 loc) · 1.31 KB
/
proxy-mock.conf.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const PROXY_CONFIG = [
{
context: '/api',
// hostname to the target server
target: 'http://localhost:8000',
// set correct host headers for name-based virtual hosted sites
changeOrigin: true,
headers: {
'Cache-Control': 'no-cache '
},
// enable websocket proxying
ws: true,
secure: false,
// rewrite paths
pathRewrite:
function (path, req) {
if(path.startsWith('/api/users/current.json')) {
return '/api/redmine-users/v1/users/1';
}
if(path.startsWith('/api/enumerations/time_entry_activities.json')) {
return '/api/redmine-activities/v1/activities/1';
}
if(path.startsWith('/api/issues.json')) {
return '/api/redmine-issues/v1/issues/1';
}
if(path.startsWith('/api/time_entries.json?issue_id=')) {
return path.replace('time_entries.json?issue_id=', 'redmine-time/v1/time_entries/').replace(/&user_id=\d*&limit=\d*/g, '');
}
if(path.startsWith('/api/time_entries.json')) {
return '/api/redmine-time/v1/time_entries/';
}
return 'unknown'
},
// control logging
logLevel: 'debug'
}
]
/**
* Create the proxy middleware, so it can be used in a server.
*/
module.exports = PROXY_CONFIG;