-
Notifications
You must be signed in to change notification settings - Fork 875
Expand file tree
/
Copy pathproxy.localhost.conf.js
More file actions
109 lines (107 loc) · 3.61 KB
/
proxy.localhost.conf.js
File metadata and controls
109 lines (107 loc) · 3.61 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright since 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
/**
* Proxy configuration for running the app against a local Fineract instance.
* Usage:
* ng serve --proxy-config proxy.localhost.conf.js
*/
module.exports = [
{
context: ['/fineract-provider'],
target: 'http://localhost:8443',
pathRewrite: { '^/fineract-provider': '' },
changeOrigin: true,
secure: false,
logLevel: 'debug',
onProxyReq: function (proxyReq, req, res) {
const rewrittenPath = (req.url || '').replace(/^\/fineract-provider/, '');
console.log('[Proxy] Proxying:', req.method, req.url, '->', this.target + rewrittenPath);
},
onError: function (err, req, res) {
console.error(
'[Proxy] Error while proxying request:',
req && req.method,
req && req.url,
'->',
this.target,
'-',
err && err.message
);
if (res && !res.headersSent) {
res.writeHead(502, { 'Content-Type': 'text/plain' });
res.end('Proxy error: ' + (err && err.message ? err.message : 'Unknown error'));
}
}
},
{
context: ['/external-nationalid'],
target: 'https://apis.mifos.community',
pathRewrite: { '^/external-nationalid': '/1.0/nationalid' },
changeOrigin: true,
secure: true,
logLevel: 'debug',
onProxyReq: function (proxyReq, req, res) {
// Inject API key server-side (same as nginx proxy_set_header in production)
const apiKey = process.env.EXTERNAL_NATIONAL_ID_SYSTEM_API_KEY || '';
if (apiKey) {
proxyReq.setHeader('X-Gravitee-Api-Key', apiKey);
}
const rewrittenPath = (req.url || '').replace(/^\/external-nationalid/, '/1.0/nationalid');
console.log('[Proxy] Proxying:', req.method, req.url, '->', this.target + rewrittenPath);
},
onError: function (err, req, res) {
console.error(
'[Proxy] Error while proxying request:',
req && req.method,
req && req.url,
'->',
this.target,
'-',
err && err.message
);
if (res && !res.headersSent) {
res.writeHead(502, { 'Content-Type': 'text/plain' });
res.end('Proxy error: ' + (err && err.message ? err.message : 'Unknown error'));
}
}
},
{
context: ['/remittance-api'],
target: 'http://54.225.231.146:8080',
pathRewrite: { '^/remittance-api': '/1.0/remittance' },
changeOrigin: true,
secure: false,
logLevel: 'debug',
onProxyReq: function (proxyReq, req, res) {
// Inject API key server-side (same as nginx proxy_set_header in production)
const apiKey = process.env.MIFOS_REMITTANCE_API_KEY || '';
const apiHeader = process.env.MIFOS_REMITTANCE_API_HEADER || 'X-Gravitee-Api-Key';
if (apiKey) {
proxyReq.setHeader(apiHeader, apiKey);
}
const rewrittenPath = (req.url || '').replace(/^\/remittance-api/, '/1.0/remittance');
console.log('[Proxy] Proxying:', req.method, req.url, '->', this.target + rewrittenPath);
},
onError: function (err, req, res) {
console.error(
'[Proxy] Error while proxying request:',
req && req.method,
req && req.url,
'->',
this.target,
'-',
err && err.message
);
if (res && !res.headersSent) {
res.writeHead(502, { 'Content-Type': 'text/plain' });
res.end('Proxy error: ' + (err && err.message ? err.message : 'Unknown error'));
}
}
}
];