mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
56af742a0b
- following on from removing api versioning logic from the frontend, it's possible to make more sense of what's happening - this commit first introduces a proper jsdoc'd object that gets passed through the frontent load & reload flow - that object contains the urlService and optionally our routeSettings processed from routes.yaml - additionally, we were passing around a start boolean, which told the routerManager whether to just init, or init+start - with this refactor, we always pass in the routeSettings when we want to do init+start, so we no longer need a boolean - The refactor itself moves logic from the reload function in site.js and urlservice + routesettings fetching logic from routes.js into the reloadFrontend function in bridge.js. - This makes it clearer to see what happens when we call reloadFrontend. - This commit also makes it clearer to see what is happening with the route settings, where they are needed and why - Ideally we'd also clean up the weird dupliated logic and somewhat unnecessary routes.js file
24 lines
909 B
JavaScript
24 lines
909 B
JavaScript
const debug = require('@tryghost/debug')('frontend');
|
|
const express = require('../../../shared/express');
|
|
const shared = require('../shared');
|
|
|
|
/**
|
|
*
|
|
* @param {import('../../../frontend/services/routing/router-manager').RouterConfig} routerConfig
|
|
* @returns {import('express').RequestHandler}
|
|
*/
|
|
module.exports = (routerConfig) => {
|
|
debug('FrontendApp setup start', routerConfig);
|
|
|
|
// FRONTEND
|
|
const frontendApp = express('frontend');
|
|
|
|
// 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.middleware.urlRedirects.frontendSSLRedirect);
|
|
|
|
frontendApp.lazyUse('/members', require('../members'));
|
|
frontendApp.use('/', require('../../../frontend/web')(routerConfig));
|
|
|
|
return frontendApp;
|
|
};
|