mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
Fixed 404 handling for {admin url}/content/* routes
no issue - added our theme error handling middleware to {admin}/content/ so that cache headers are properly set for 404s - only registered {admin}/content when a separate admin url is configured so that we're not overriding {site}/content
This commit is contained in:
parent
6feeb67d84
commit
717567995b
@ -44,20 +44,31 @@ module.exports = function setupParentApp(options = {}) {
|
||||
// This sets global res.locals which are needed everywhere
|
||||
parentApp.use(shared.middlewares.ghostLocals);
|
||||
|
||||
// Wrap the admin and API apps into a single express app for use with vhost
|
||||
const adminApp = express();
|
||||
adminApp.enable('trust proxy'); // required to respect x-forwarded-proto in admin requests
|
||||
adminApp.use('/ghost/api', require('./api')());
|
||||
adminApp.use('/ghost', require('./admin')());
|
||||
// TODO: remove /content/* once we're sure the API is not returning relative asset URLs anywhere
|
||||
adminApp.use(STATIC_IMAGE_URL_PREFIX, shared.middlewares.image.handleImageSizes, storage.getStorage().serve());
|
||||
|
||||
// Mount the apps on the parentApp
|
||||
|
||||
const adminHost = config.get('admin:url') ? (new URL(config.get('admin:url')).hostname) : '';
|
||||
const frontendHost = new URL(config.get('url')).hostname;
|
||||
const hasSeparateAdmin = adminHost && adminHost !== frontendHost;
|
||||
|
||||
// Wrap the admin and API apps into a single express app for use with vhost
|
||||
const adminApp = express();
|
||||
adminApp.enable('trust proxy'); // required to respect x-forwarded-proto in admin requests
|
||||
adminApp.use('/ghost/api', require('./api')());
|
||||
adminApp.use('/ghost', require('./admin')());
|
||||
|
||||
// TODO: remove {admin url}/content/* once we're sure the API is not returning relative asset URLs anywhere
|
||||
// only register this route if the admin is separate so we're not overriding the {site}/content/* route
|
||||
if (hasSeparateAdmin) {
|
||||
adminApp.use(
|
||||
STATIC_IMAGE_URL_PREFIX,
|
||||
[
|
||||
shared.middlewares.image.handleImageSizes,
|
||||
storage.getStorage().serve(),
|
||||
shared.middlewares.errorHandler.handleThemeResponse
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// ADMIN + API
|
||||
// with a separate admin url only serve on that host, otherwise serve on all hosts
|
||||
const adminVhostArg = hasSeparateAdmin && adminHost ? adminHost : /.*/;
|
||||
|
Loading…
Reference in New Issue
Block a user