Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module.exports = { | ||
getDeployedAppsProxy: function(processHost, deployedApps) { | ||
let deployedAppProxy = {}; | ||
|
||
if (deployedApps) { | ||
try { | ||
const deployedAppsArray = JSON.parse(deployedApps); | ||
for (const app of deployedAppsArray) { | ||
const appName = app.name; | ||
const appPath = `/${appName}`; | ||
const appPathRewrite = `^/${appName}`; | ||
|
||
deployedAppProxy = { | ||
...deployedAppProxy, | ||
[appPath]: { | ||
target: `${processHost}`, | ||
secure: false, | ||
pathRewrite: { | ||
[appPathRewrite]: appName, | ||
}, | ||
changeOrigin: true, | ||
}, | ||
}; | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
return deployedAppProxy; | ||
}, | ||
getShareProxy: function(host) { | ||
console.log('Target for /alfresco', host); | ||
return { | ||
'/alfresco': { | ||
target: host, | ||
secure: false, | ||
logLevel: 'debug', | ||
changeOrigin: true, | ||
onProxyReq: function(request) { | ||
if(request["method"] !== "GET") | ||
request.setHeader("origin", host); | ||
}, | ||
// workaround for REPO-2260 | ||
onProxyRes: function (proxyRes, req, res) { | ||
const header = proxyRes.headers['www-authenticate']; | ||
if (header && header.startsWith('Basic')) { | ||
proxyRes.headers['www-authenticate'] = 'x' + header; | ||
} | ||
}, | ||
}, | ||
} | ||
}, | ||
getApsProxy: function(host) { | ||
console.log('Target for /activiti-app', host); | ||
return { | ||
'/activiti-app': { | ||
target: host, | ||
secure: false, | ||
logLevel: 'debug', | ||
changeOrigin: true, | ||
}, | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,14 @@ | ||
require('dotenv').config(); | ||
|
||
var PROXY_HOST_ADF = process.env.PROXY_HOST_ADF; | ||
console.log('PROXY_HOST_ADF' + PROXY_HOST_ADF); | ||
const { getDeployedAppsProxy, getShareProxy, getApsProxy } = require('./proxy-helpers'); | ||
|
||
const legacyHost = process.env.PROXY_HOST_ADF; | ||
const cloudHost = process.env.CLOUD_PROXY_HOST_ADF; | ||
const cloudApps = process.env.APP_CONFIG_APPS_DEPLOYED; | ||
const apsHost = process.env.PROXY_HOST_ADF; | ||
|
||
module.exports = { | ||
"/alfresco": { | ||
"target": (PROXY_HOST_ADF || "http://localhost:8080"), | ||
"secure": false, | ||
"pathRewrite": { | ||
"^/alfresco/alfresco": "" | ||
}, | ||
"changeOrigin": true, | ||
// workaround for REPO-2260 | ||
onProxyRes: function (proxyRes, req, res) { | ||
const header = proxyRes.headers['www-authenticate']; | ||
if (header && header.startsWith('Basic')) { | ||
proxyRes.headers['www-authenticate'] = 'x' + header; | ||
} | ||
} | ||
}, | ||
"/activiti-app": { | ||
"target": (PROXY_HOST_ADF || "http://localhost:8080"), | ||
"secure": false, | ||
"pathRewrite": { | ||
"^/activiti-app/activiti-app": "" | ||
}, | ||
"changeOrigin": true | ||
} | ||
...getShareProxy(legacyHost), | ||
...getApsProxy(apsHost), | ||
...getDeployedAppsProxy(cloudHost, cloudApps) | ||
}; |