From 07c627c33328d2eba54d3c412159f96090c7aa19 Mon Sep 17 00:00:00 2001 From: Okabe Rintaro Date: Mon, 7 Feb 2022 14:57:22 +0200 Subject: [PATCH] use correct urls for projects running with SSL enabled --- build-packages/magento-scripts/lib/commands/start.js | 6 ++++-- .../lib/tasks/magento/setup-magento/set-base-url.js | 6 +++--- build-packages/magento-scripts/lib/tasks/start.js | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build-packages/magento-scripts/lib/commands/start.js b/build-packages/magento-scripts/lib/commands/start.js index aef22137..0c647580 100644 --- a/build-packages/magento-scripts/lib/commands/start.js +++ b/build-packages/magento-scripts/lib/commands/start.js @@ -95,12 +95,14 @@ module.exports = (yargs) => { systemConfiguration: { analytics } } = ctx; + const webLocation = `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`; + const block = new ConsoleBlock(); block .addHeader('Magento 2') .addEmptyLine() - .addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`) - .addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`) + .addLine(`Web location: ${logger.style.link(webLocation)}`) + .addLine(`Magento Admin panel location: ${logger.style.link(`${webLocation}${magentoConfiguration.adminuri}`)}`) .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`); const themes = await getCSAThemes(); diff --git a/build-packages/magento-scripts/lib/tasks/magento/setup-magento/set-base-url.js b/build-packages/magento-scripts/lib/tasks/magento/setup-magento/set-base-url.js index d3afde7e..122646c7 100644 --- a/build-packages/magento-scripts/lib/tasks/magento/setup-magento/set-base-url.js +++ b/build-packages/magento-scripts/lib/tasks/magento/setup-magento/set-base-url.js @@ -11,11 +11,11 @@ module.exports = () => ({ config: { overridenConfiguration: { host, ssl } }, mysqlConnection } = ctx; + const enableSecureFrontend = ssl.enabled ? '1' : '0'; const location = `${host}${ ports.app !== 80 ? `:${ports.app}` : '' }/`; + const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time. const httpUrl = `http://${location}`; - const httpsUrl = `https://${location}`; - - const enableSecureFrontend = ssl.enabled ? '1' : '0'; + const httpsUrl = `https://${secureLocation}`; await updateTableValues('core_config_data', [ { path: 'web/unsecure/base_url', value: httpUrl }, diff --git a/build-packages/magento-scripts/lib/tasks/start.js b/build-packages/magento-scripts/lib/tasks/start.js index 47a81695..2aa9400a 100644 --- a/build-packages/magento-scripts/lib/tasks/start.js +++ b/build-packages/magento-scripts/lib/tasks/start.js @@ -174,7 +174,7 @@ const start = () => ({ title: 'Opening browser', skip: (ctx) => ctx.noOpen, task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => { - openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`); + openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`); }, options: { showTimer: false