1 const mockApis = require('./configurations/mock.json').sdcConfig;
2 const proxy = require('http-proxy-middleware');
5 const feHost = "localhost";
6 const portalCookieValue = "randomValue"; //for dev solely, in production - the webseal would add the cookie by itself.
8 module.exports = function (env) {
10 // Set default user role
16 console.log("Starting dev server with role: " + env.role);
18 const serverConfig = {
20 historyApiFallback: true,
24 exclude: ['node_modules']
27 let userType = mockApis.userTypes[env.role];
31 res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId);
32 res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email);
33 res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName);
34 res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName);
35 res.cookie(mockApis.cookie.portalCookie, portalCookieValue);
40 // Redirect all '/sdc1/feProxy/rest' to feHost
42 proxy(['/sdc1/feProxy/rest', '/sdc1/feProxy/uicache'], {
43 target: 'http://' + feHost + ':' + fePort,
48 // Redirect all '/sdc1/rest' to feHost
50 proxy(['/sdc1/rest'], {
51 target: 'http://' + feHost + ':' + fePort,
56 // Redirect dcae urls to feHost
58 proxy(['/dcae', '/sdc1/feProxy/dcae-api'], {
59 target: 'http://' + feHost + ':' + fePort,
62 onProxyRes: (proxyRes, req, res) => {
63 let setCookie = proxyRes.headers['set-cookie'];
65 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
70 // Redirect onboarding urls to feHost
72 proxy(['/onboarding', '/sdc1/feProxy/onboarding-api'], {
73 target: 'http://' + feHost + ':' + fePort,
76 onProxyRes: (proxyRes, req, res) => {
77 let setCookie = proxyRes.headers['set-cookie'];
79 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
84 server.use(middlewares);