WEB-547 feat(proxy): forward /fineract-provider to sandbox; add localhost sample and README MD034 fixes (#2958)
This commit is contained in:
+26
-5
@@ -2,7 +2,7 @@
|
||||
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
|
||||
/*
|
||||
/* IMPORTANT:
|
||||
* API proxy configuration.
|
||||
* This allows you to proxy HTTP request like `http.get('/api/stuff')` to another server/port.
|
||||
* This is especially useful during app development to avoid CORS issues while running a local server.
|
||||
@@ -10,12 +10,33 @@ const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
*/
|
||||
const proxyConfig = [
|
||||
{
|
||||
context: '/api',
|
||||
pathRewrite: { '^/api': '' },
|
||||
target: 'https://api.chucknorris.io',
|
||||
context: ['/fineract-provider'],
|
||||
target: 'https://sandbox.mifos.community',
|
||||
pathRewrite: { '^/fineract-provider': '' },
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
secure: true,
|
||||
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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
// For local development use `proxy.localhost.conf js` .
|
||||
];
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user