mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Moved vhost mounts into boot file
- This stops the mounting of the admin and frontend from being buried deep in express initialisation - Instead it's explicit, which makes two things almost possible: 1. we can potentially boot the frontend or backend independently 2. we can pass services and settings loaded during boot into the frontend - This needs more work, but we can start to group all the frontend code together - Meanwhile we also need to rip apart the routing and url services to decouple the frontend from the backend fully - BABY STEPS!
This commit is contained in:
parent
3c9f5da39d
commit
7e61f73b8c
12
core/boot.js
12
core/boot.js
@ -131,6 +131,18 @@ 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;
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ 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(options = {}) {
|
||||
module.exports = function setupParentApp() {
|
||||
debug('ParentApp setup start');
|
||||
const parentApp = express('parent');
|
||||
|
||||
@ -25,17 +23,9 @@ module.exports = function setupParentApp(options = {}) {
|
||||
// @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');
|
||||
|
@ -1,5 +1,6 @@
|
||||
const debug = require('@tryghost/debug')('web:backend');
|
||||
const express = require('../../../shared/express');
|
||||
const vhostUtils = require('./vhost-utils');
|
||||
|
||||
/**
|
||||
*
|
||||
@ -10,6 +11,9 @@ 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')());
|
||||
|
@ -1,5 +1,6 @@
|
||||
const debug = require('@tryghost/debug')('frontend');
|
||||
const express = require('../../../shared/express');
|
||||
const vhostUtils = require('./vhost-utils');
|
||||
|
||||
const shared = require('../shared');
|
||||
|
||||
@ -14,6 +15,8 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user