1 let path = require('path');
3 const mockApis = require('./configurations/mock.json').sdcConfig;
4 const proxy = require('http-proxy-middleware');
7 const localhost = "localhost";
9 module.exports = function(env) {
17 console.log("Starting dev server with role: " + env.role);
19 const ServerConfig = {
21 historyApiFallback: true,
25 exclude: ['node_modules']
28 let userType = mockApis.userTypes[env.role];
32 res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId);
33 res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email);
34 res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName);
35 res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName);
40 // Redirect all '/sdc1/feProxy/rest' to feHost
42 proxy(['/sdc1/feProxy/rest'], {
43 target: 'http://' + localhost + ':' + fePort,
48 // Redirect all '/sdc1/rest' to feHost
50 proxy(['/sdc1/rest'],{
51 target: 'http://' + localhost + ':' + fePort,
56 // Redirect dcae urls to feHost
58 proxy(['/dcae','/sdc1/feProxy/dcae-api'], {
59 target: 'http://' + localhost + ':' + 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://' + localhost + ':' + fePort,
76 onProxyRes: (proxyRes, req, res) => {
77 let setCookie = proxyRes.headers['set-cookie'];
79 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
84 // Redirect workflow urls to feHost
86 proxy(['/sdc1/feProxy/wf', '/wf'], {
87 target: 'http://' + localhost + ':' + fePort,
90 onProxyRes: (proxyRes, req, res) => {
91 let setCookie = proxyRes.headers['set-cookie'];
93 setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, '');
98 server.use(middlewares);