summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/proxy-server.js
diff options
context:
space:
mode:
authorAvi Ziv <AVIZI@amdocs.com>2017-07-26 17:37:57 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-26 18:27:22 +0300
commit61070c9c6b665fdea79b3ccdfeafc3a6b50d262e (patch)
treedfe9c169cfac91d6c72ac9ff23375f2aafac6405 /openecomp-ui/proxy-server.js
parentb824a997e19f6ee9627cb1b1e124c756bd8183fc (diff)
[SDC] Full OnBoard health-check and NFoD support
Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/proxy-server.js')
-rw-r--r--openecomp-ui/proxy-server.js92
1 files changed, 0 insertions, 92 deletions
diff --git a/openecomp-ui/proxy-server.js b/openecomp-ui/proxy-server.js
deleted file mode 100644
index 4733d38a89..0000000000
--- a/openecomp-ui/proxy-server.js
+++ /dev/null
@@ -1,92 +0,0 @@
-'use strict';
-
-const proxy = require('http-proxy-middleware');
-
-let localDevConfig = {};
-try {
- localDevConfig = require('./devConfig');
-} catch (e) {}
-const devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig);
-let devPort = process.env.PORT || devConfig.port;
-
-let jsonConfig = {
- "appContextPath" : "/onboarding"
-};
-
-try {
- jsonConfig = require('./src/sdc-app/config/config.json');
-} catch (e) {
- console.log('could not load config. using deault value instead');
-}
-
-module.exports = function (server) {
- let proxyConfigDefaults = {
- changeOrigin: true,
- secure: false,
- onProxyRes: (proxyRes, req, res) => {
- let setCookie = proxyRes.headers['set-cookie'];
- if (setCookie) {
- setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
- }
- if (proxyRes.statusCode === 302 && proxyRes.headers.location.indexOf('login') > -1) {
- proxyRes.headers.location = `http://localhost:${devPort}/sdc1#/onboardVendor`;
- res.setHeader('Set-Cookie', [
- 'HTTP_CSP_EMAIL=csantana@sdc.com',
- 'HTTP_CSP_FIRSTNAME=Carlos',
- 'HTTP_CSP_LASTNAME=Santana',
- 'HTTP_CSP_WSTYPE=Intranet',
- 'HTTP_IV_REMOTE_ADDRESS=0.0.0.0',
- 'HTTP_IV_USER=cs0008',
- 'USER_ID=cs0008'
- ]);
- }
- }
- };
-
- let middlewares = [
- (req, res, next) => {
- if (req.url.indexOf('/proxy-designer1') > -1) {
- req.url = req.url.replace('/proxy-designer1', '');
- }
-
- if (req.url.indexOf(jsonConfig.appContextPath + '/resources') > -1) {
- req.url = req.url.replace(jsonConfig.appContextPath, '');
- }
-
- let match = req.url.match(/^(.*)_en.js$/);
- let newUrl = match && match[1] + '.js';
- if (newUrl) {
- console.log(`REWRITING URL: ${req.url} -> ${newUrl}`);
- req.url = newUrl;
- }
- next();
- }
- ];
-
- // standalon back-end (proxyTarget) has higher priority, so it should be first
- if (devConfig.proxyTarget) {
- middlewares.push(
- proxy(['/api', '/onboarding-api', '/sdc1/feProxy/onboarding-api'], Object.assign({}, proxyConfigDefaults, {
- target: devConfig.proxyTarget,
- pathRewrite: {
- '/sdc1/feProxy/onboarding-api': '/onboarding-api'
- }
- }))
- );
- }
-
- // ATT environment (proxyATTTarget) has lower priority, so it should be second
- if (devConfig.proxyATTTarget) {
- middlewares.push(
- proxy(['/sdc1', '/onboarding-api', '/scripts', '/styles'], Object.assign({}, proxyConfigDefaults, {
- target: devConfig.proxyATTTarget,
- pathRewrite: {
- // Workaround for some weird proxy issue
- '/sdc1/feProxy/onboarding-api': '/sdc1/feProxy/onboarding-api',
- '/onboarding-api': '/sdc1/feProxy/onboarding-api'
- }
- }))
- );
- }
- server.use(middlewares);
-};