Moved admin-redirects mw into site app

- Moved admin-redirects from shared to site as it is not shared
- This file is only used in one place, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
This commit is contained in:
Hannah Wolfe 2020-04-21 12:08:07 +01:00
parent 6fd4c65421
commit c3f4b7a57c
4 changed files with 7 additions and 5 deletions

View File

@ -11,10 +11,6 @@ module.exports = {
return require('./validation');
},
get adminRedirects() {
return require('./admin-redirects');
},
get brute() {
return require('./brute');
},

View File

@ -19,6 +19,7 @@ const membersService = require('../../services/members');
const membersMiddleware = membersService.middleware;
const siteRoutes = require('./routes');
const shared = require('../shared');
const mw = require('./middleware');
const sentry = require('../../sentry');
const STATIC_IMAGE_URL_PREFIX = `/${urlUtils.STATIC_IMAGE_URL_PREFIX}`;
@ -96,7 +97,7 @@ module.exports = function setupSiteApp(options = {}) {
shared.middlewares.customRedirects.use(siteApp);
// More redirects
siteApp.use(shared.middlewares.adminRedirects());
siteApp.use(mw.adminRedirects());
// 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.

View File

@ -12,6 +12,8 @@ const adminRedirect = (path) => {
module.exports = function adminRedirects() {
const router = express.Router();
console.log('loading admin redirects');
if (config.get('admin:redirects')) {
router.get(/^\/ghost\/?$/, adminRedirect('/'));
}

View File

@ -0,0 +1,3 @@
module.exports = {
adminRedirects: require('./admin-redirects')
};