1 const mockApis = require('./configurations/mock.json').sdcConfig;
2 const proxy = require('http-proxy-middleware');
6 const feHost = "localhost";
8 const isDirectToFE = true;
10 const portalCookieValue = "randomValue"; //for dev solely, in production - the webseal would add the cookie by itself.
12 module.exports = function (env) {
14 // Set default user role
20 console.log("Starting dev server with role: " + env.role);
22 const serverConfig = {
24 historyApiFallback: true,
28 exclude: ['node_modules']
31 let userType = mockApis.userTypes[env.role];
35 res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId);
36 res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email);
37 res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName);
38 res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName);
39 res.cookie(mockApis.cookie.portalCookie, portalCookieValue);
44 // Redirect all '/sdc1/feProxy/rest' to feHost
45 let feProxyOptions = {
46 target: protocol + '://' + feHost + ':' + fePort,
52 feProxyOptions.pathRewrite= {
53 '^/sdc1/feProxy/rest' : '/sdc2/rest'
57 proxy(['/sdc1/feProxy/rest'], feProxyOptions));
59 // Redirect all '/sdc1/rest' to feHost
61 proxy(['/sdc1/rest'],{
62 target: protocol + '://' + feHost + ':' + fePort,
67 // Redirect dcae urls to feHost
69 proxy(['/dcae','/sdc1/feProxy/dcae-api'], {
70 target: protocol + '://' + feHost + ':' + fePort,
73 onProxyRes: (proxyRes, req, res) => {
74 let setCookie = proxyRes.headers['set-cookie'];
76 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
81 // Redirect onboarding urls to feHost
83 proxy(['/onboarding', '/sdc1/feProxy/onboarding-api'], {
84 target: protocol + '://' + feHost + ':' + fePort,
87 onProxyRes: (proxyRes, req, res) => {
88 let setCookie = proxyRes.headers['set-cookie'];
90 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
95 // Redirect workflow urls to feHost
97 proxy(['/wf', '/sdc1/feProxy/wf'], {
98 target: protocol + '://' + feHost + ':' + fePort,
102 onProxyRes: (proxyRes, req, res) => {
103 let setCookie = proxyRes.headers['set-cookie'];
105 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
109 server.use(middlewares);