-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy.conf.js
More file actions
30 lines (26 loc) · 916 Bytes
/
proxy.conf.js
File metadata and controls
30 lines (26 loc) · 916 Bytes
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
const url = require('url');
require('dotenv').config({ path: ['.env', process.env.NODE_ENV].filter(Boolean).join('.') });
const { PROXY_TARGET } = process.env;
const REQUIRED_ENV = [PROXY_TARGET];
if (REQUIRED_ENV.findIndex((e) => !e) !== -1) {
throw new Error('[proxy.conf.js] Set required environment variables!');
}
module.exports = {
// http://localhost/__api -> https://api.target.com
'/__api': {
target: `https://api.${PROXY_TARGET}`,
secure: false,
changeOrigin: true,
pathRewrite: { '^/__api': '' },
logLevel: 'debug',
headers: { Origin: `https://dashboard.${PROXY_TARGET}` },
},
'/__shrt': {
target: `https://shrt.${PROXY_TARGET}`,
secure: false,
changeOrigin: true,
pathRewrite: { '^/__shrt': '' },
logLevel: 'debug',
headers: { Origin: `https://dashboard.${PROXY_TARGET}` },
},
};