diff --git a/core/boot.js b/core/boot.js index 8effee0930..488c5fa355 100644 --- a/core/boot.js +++ b/core/boot.js @@ -131,18 +131,6 @@ async function initFrontend() { async function initExpressApps() { debug('Begin: initExpressApps'); const parentApp = require('./server/web/parent/app')(); - const vhost = require('@tryghost/vhost-middleware'); - - // Mount the express apps on the parentApp - - // ADMIN + API - const backendApp = require('./server/web/parent/backend')(); - parentApp.use(vhost(backendApp.get('vhostArg'), backendApp)); - - // SITE + MEMBERS - const frontendApp = require('./server/web/parent/frontend')({}); - parentApp.use(vhost(frontendApp.get('vhostArg'), frontendApp)); - debug('End: initExpressApps'); return parentApp; } diff --git a/core/server/web/parent/app.js b/core/server/web/parent/app.js index 2b6780f464..6c5b226277 100644 --- a/core/server/web/parent/app.js +++ b/core/server/web/parent/app.js @@ -3,8 +3,10 @@ const config = require('../../../shared/config'); const express = require('../../../shared/express'); const compress = require('compression'); const mw = require('./middleware'); +const vhost = require('@tryghost/vhost-middleware'); +const vhostUtils = require('./vhost-utils'); -module.exports = function setupParentApp() { +module.exports = function setupParentApp(options = {}) { debug('ParentApp setup start'); const parentApp = express('parent'); @@ -23,9 +25,17 @@ module.exports = function setupParentApp() { // @TODO: figure out if this is really needed everywhere? Is it not frontend only... parentApp.use(mw.ghostLocals); + // Mount the express apps on the parentApp + + // ADMIN + API + const backendApp = require('./backend')(); + parentApp.use(vhost(vhostUtils.getBackendHostArg(), backendApp)); + + // SITE + MEMBERS + const frontendApp = require('./frontend')(options); + parentApp.use(vhost(vhostUtils.getFrontendHostArg(), frontendApp)); + debug('ParentApp setup end'); return parentApp; }; - -// const vhostUtils = require('./vhost-utils'); diff --git a/core/server/web/parent/backend.js b/core/server/web/parent/backend.js index 64ab05e05c..2e40dae378 100644 --- a/core/server/web/parent/backend.js +++ b/core/server/web/parent/backend.js @@ -1,6 +1,5 @@ const debug = require('@tryghost/debug')('web:backend'); const express = require('../../../shared/express'); -const vhostUtils = require('./vhost-utils'); /** * @@ -11,9 +10,6 @@ module.exports = () => { // BACKEND // Wrap the admin and API apps into a single express app for use with vhost const backendApp = express('backend'); - - backendApp.set('vhostArg', vhostUtils.getBackendHostArg()); - backendApp.use('/ghost/api', require('../api')()); backendApp.use('/ghost/oauth', require('../oauth')()); backendApp.use('/ghost/.well-known', require('../well-known')()); diff --git a/core/server/web/parent/frontend.js b/core/server/web/parent/frontend.js index cea8c5e265..6276195eef 100644 --- a/core/server/web/parent/frontend.js +++ b/core/server/web/parent/frontend.js @@ -1,6 +1,5 @@ const debug = require('@tryghost/debug')('frontend'); const express = require('../../../shared/express'); -const vhostUtils = require('./vhost-utils'); const shared = require('../shared'); @@ -15,8 +14,6 @@ module.exports = (options) => { // FRONTEND const frontendApp = express('frontend'); - frontendApp.set('vhostArg', vhostUtils.getFrontendHostArg()); - // Force SSL if blog url is set to https. The redirects handling must happen before asset and page routing, // otherwise we serve assets/pages with http. This can cause mixed content warnings in the admin client. frontendApp.use(shared.middlewares.urlRedirects.frontendSSLRedirect);