Added static file handling to the frontend

refs https://github.com/TryGhost/Toolbox/issues/114

- Static files uploaded through the Admin Files API should be accessible throught the world under `/content/files/`
- Note the feature is behind an alpha "filesAPI" flag, which has to be enabled in the labs first
This commit is contained in:
Naz 2021-11-08 11:44:46 +04:00
parent b7d8d70ccf
commit be748f2f6d

View File

@ -25,6 +25,7 @@ const labs = require('../../shared/labs');
const STATIC_IMAGE_URL_PREFIX = `/${urlUtils.STATIC_IMAGE_URL_PREFIX}`;
const STATIC_MEDIA_URL_PREFIX = `/${constants.STATIC_MEDIA_URL_PREFIX}`;
const STATIC_FILES_URL_PREFIX = `/${constants.STATIC_FILES_URL_PREFIX}`;
let router;
@ -117,6 +118,8 @@ module.exports = function setupSiteApp(options = {}) {
siteApp.use(STATIC_IMAGE_URL_PREFIX, mw.handleImageSizes, storage.getStorage('images').serve());
// Serve blog media using the storage adapter
siteApp.use(STATIC_MEDIA_URL_PREFIX, labs.enabledMiddleware('mediaAPI'), storage.getStorage('media').serve());
// Serve blog files using the storage adapter
siteApp.use(STATIC_FILES_URL_PREFIX, labs.enabledMiddleware('filesAPI'), storage.getStorage('files').serve());
// Global handling for member session, ensures a member is logged in to the frontend
siteApp.use(membersService.middleware.loadMemberSession);