2021-07-06 11:02:37 +01:00
|
|
|
const debug = require('@tryghost/debug')('frontend');
|
2021-06-28 14:27:22 +01:00
|
|
|
const express = require('../../../shared/express');
|
|
|
|
const shared = require('../shared');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2022-04-13 11:09:22 +01:00
|
|
|
* @param {import('../../../frontend/services/routing/router-manager').RouterConfig} routerConfig
|
2021-06-28 14:27:22 +01:00
|
|
|
* @returns {import('express').RequestHandler}
|
|
|
|
*/
|
2022-04-13 11:09:22 +01:00
|
|
|
module.exports = (routerConfig) => {
|
|
|
|
debug('FrontendApp setup start', routerConfig);
|
2021-06-28 14:27:22 +01:00
|
|
|
|
|
|
|
// 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.
|
2021-11-16 15:42:02 +00:00
|
|
|
frontendApp.use(shared.middleware.urlRedirects.frontendSSLRedirect);
|
2021-06-28 14:27:22 +01:00
|
|
|
|
2021-10-11 12:06:03 +02:00
|
|
|
frontendApp.lazyUse('/members', require('../members'));
|
2022-04-13 11:09:22 +01:00
|
|
|
frontendApp.use('/', require('../../../frontend/web')(routerConfig));
|
2021-06-28 14:27:22 +01:00
|
|
|
|
|
|
|
return frontendApp;
|
|
|
|
};
|