Skip to content

Commit

Permalink
Merge pull request #1975 from dlabrecq/insights-proxy
Browse files Browse the repository at this point in the history
Refactored webpack to work with Insights proxy
  • Loading branch information
dlabrecq authored May 27, 2021
2 parents 8321493 + 33ec3e3 commit 39f4f62
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
8 changes: 4 additions & 4 deletions config/spandx.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ const localhost = process.env.PLATFORM === 'linux' ? 'localhost' : 'host.docker.
module.exports = {
routes: {
'/apps/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
'/beta/apps/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
// New URLs
'/openshift/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
'/beta/openshift/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
// For testing cloud-services-config https://github.com/RedHatInsights/cloud-services-config#testing-your-changes-locally
// '/beta/config': {
Expand Down
19 changes: 16 additions & 3 deletions scripts/start-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ const { spawn } = require('child_process');
async function setEnv() {
return inquirer
.prompt([
{ type: 'list', name: 'uiEnv', message: 'Which UI environment you want to use?', choices: ['stable', 'beta'] },
{ type: 'list', name: 'uiEnv', message: 'Which UI environment you want to use?', choices: ['beta', 'stable'] },
{
type: 'list',
name: 'clouddotEnv',
message: 'Which platform environment you want to use',
choices: ['ci', 'qa', 'prod'],
},
{
name: 'insightsProxy',
message: 'Do you want to use the Insights proxy?',
type: 'confirm',
default: false,
},
// {
// name: 'localApi',
// message: 'Do you want to use local api?',
// type: 'confirm',
// default: false,
// },
])
.then(answers => {
const { uiEnv, clouddotEnv } = answers;
const { uiEnv, clouddotEnv, insightsProxy, localApi } = answers;

process.env.BETA_ENV = uiEnv === 'beta' ? 'true' : 'false';
process.env.CLOUDOT_ENV = clouddotEnv;
process.env.USE_PROXY = 'true';
process.env.USE_PROXY = (!insightsProxy).toString(); // Set 'true' for webpack proxy
// process.env.USE_LOCAL_ROUTES = localApi.toString();
});
}

Expand Down
25 changes: 21 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = (_env, argv) => {
log.info(`Beta branches: ${betaBranches}`);
log.info(`Using deployments: ${appDeployment}`);
log.info(`Public path: ${publicPath}`);
log.info(`Using Insights proxy: ${!useProxy}`);
log.info('~~~~~~~~~~~~~~~~~~~~~');

const stats = {
Expand All @@ -90,6 +91,7 @@ module.exports = (_env, argv) => {
const routes = {
// For local API development
// '/api/cost-management/v1/': { host: 'http://localhost:8000' },
//
// For testing cloud-services-config https://github.com/RedHatInsights/cloud-services-config#testing-your-changes-locally
// '/beta/config': {
// host: `http://${localhost}:8889`,
Expand Down Expand Up @@ -257,19 +259,34 @@ module.exports = (_env, argv) => {
routes,
})
: {
host: 'localhost',
port: 8002,
stats,
contentBase: false,
historyApiFallback: {
index: `${publicPath}index.html`,
},
// hot: !isProduction,
hot: false, // default is true, which currently does not work with Insights and federated modules?
firewall: false,
transportMode: 'sockjs',
port: 8002,
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
},
// Props for webpack-dev-server v4.0.0-beta.2
//
// host: 'localhost',
// port: 8002,
// historyApiFallback: {
// index: `${publicPath}index.html`,
// },
// // hot: !isProduction,
// hot: false, // default is true, which currently does not work with Insights and federated modules?
// firewall: false,
// transportMode: 'sockjs',
// headers: {
// 'Access-Control-Allow-Origin': '*',
// 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
// },
},
};
};

0 comments on commit 39f4f62

Please sign in to comment.