diff --git a/server.ts b/server.ts index 07a05656d87..33e2df0a68d 100644 --- a/server.ts +++ b/server.ts @@ -72,6 +72,16 @@ const cookieParser = require('cookie-parser'); const appConfig: AppConfig = buildAppConfig(join(DIST_FOLDER, 'assets/config.json')); +// only enable SSR for paths in the sitemap +const SSR_PATHS = [ + '/items/', + '/entities/', + '/collections/', + '/communities/', + '/bitstream/', + '/bitstreams/' +]; + // cache of SSR pages for known bots, only enabled in production mode let botCache: LRU; @@ -218,7 +228,7 @@ export function app() { * The callback function to serve server side angular */ function ngApp(req, res, next) { - if (environment.ssr.enabled) { + if (environment.ssr.enabled && req.method === 'GET' && SSR_PATHS.some(p => req.url.includes(p))) { // Render the page to user via SSR (server side rendering) serverSideRender(req, res, next); } else {