1 let path = require('path');
3 const mockApis = require('./configurations/mock.json').sdcConfig;
4 const proxy = require('http-proxy-middleware');
7 const loclahost = "localhost"; // "localhost"
8 const portalCookieValue = "randomValue"; //for dev solely, in production - the webseal would add the cookie byitself.
10 module.exports = function(env) {
18 console.log("Starting dev server with role: " + env.role);
20 const ServerConfig = {
22 historyApiFallback: true,
26 exclude: ['node_modules']
29 let userType = mockApis.userTypes[env.role];
33 res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId);
34 res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email);
35 res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName);
36 res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName);
37 res.cookie(mockApis.cookie.portalCookie, portalCookieValue);
42 // Redirect all '/sdc1/feProxy/rest' to feHost
44 proxy(['/sdc1/feProxy/rest', '/sdc1/feProxy/uicache'],{
45 target: 'http://' + loclahost + ':' + fePort,
50 // Redirect all '/sdc1/rest' to feHost
52 proxy(['/sdc1/rest'],{
53 target: 'http://' + loclahost + ':' + fePort,
58 // Redirect dcae urls to feHost
60 proxy(['/dcae','/sdc1/feProxy/dcae-api'],{
61 target: 'http://' + loclahost + ':' + fePort,
64 onProxyRes: (proxyRes, req, res) => {
65 let setCookie = proxyRes.headers['set-cookie'];
67 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
72 // Redirect onboarding urls to feHost
74 proxy(['/onboarding','/sdc1/feProxy/onboarding-api'],{
75 target: 'http://' + loclahost + ':' + fePort,
78 onProxyRes: (proxyRes, req, res) => {
79 let setCookie = proxyRes.headers['set-cookie'];
81 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
86 server.use(middlewares);