2021-07-06 13:02:37 +03:00
|
|
|
const debug = require('@tryghost/debug')('frontend');
|
2021-06-28 16:27:22 +03:00
|
|
|
const express = require('../../../shared/express');
|
|
|
|
|
|
|
|
const shared = require('../shared');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {object} options
|
|
|
|
* @returns {import('express').RequestHandler}
|
|
|
|
*/
|
|
|
|
module.exports = (options) => {
|
2021-07-06 13:02:37 +03:00
|
|
|
debug('FrontendApp setup start', options);
|
2021-06-28 16:27:22 +03: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.
|
|
|
|
frontendApp.use(shared.middlewares.urlRedirects.frontendSSLRedirect);
|
|
|
|
|
|
|
|
frontendApp.use('/members', require('../members')());
|
|
|
|
frontendApp.use('/', require('../site')(options));
|
|
|
|
|
|
|
|
return frontendApp;
|
|
|
|
};
|