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/feProxy/uicache' to feHost
61 proxy(['/sdc1/feProxy/uicache'], {
62 target: protocol + '://' + feHost + ':' + fePort,
67 // Redirect all '/sdc1/rest' to feHost
69 proxy(['/sdc1/rest'],{
70 target: protocol + '://' + feHost + ':' + fePort,
75 // Redirect dcae urls to feHost
77 proxy(['/dcae','/sdc1/feProxy/dcae-api'], {
78 target: protocol + '://' + feHost + ':' + fePort,
81 onProxyRes: (proxyRes, req, res) => {
82 let setCookie = proxyRes.headers['set-cookie'];
84 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
89 // Redirect onboarding urls to feHost
91 proxy(['/onboarding', '/sdc1/feProxy/onboarding-api'], {
92 target: protocol + '://' + feHost + ':' + fePort,
95 onProxyRes: (proxyRes, req, res) => {
96 let setCookie = proxyRes.headers['set-cookie'];
98 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
103 // Redirect workflow urls to feHost
105 proxy(['/wf', '/sdc1/feProxy/wf'], {
106 target: protocol + '://' + feHost + ':' + fePort,
110 onProxyRes: (proxyRes, req, res) => {
111 let setCookie = proxyRes.headers['set-cookie'];
113 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
117 server.use(middlewares);