From 9a681b2cc7d77ae9c69e63f263f861e795061925 Mon Sep 17 00:00:00 2001 From: ehg Date: Fri, 15 Jan 2016 11:56:10 +0000 Subject: [PATCH] SSR: Enable server side rendering based on feature flag Enabled in all environments except stage and production. --- config/development.json | 1 + config/horizon.json | 1 + config/production.json | 1 + config/stage.json | 1 + config/wpcalypso.json | 1 + server/pages/index.js | 12 +++++++----- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config/development.json b/config/development.json index b01f9f8efd3dd..32f7b1397dc5d 100644 --- a/config/development.json +++ b/config/development.json @@ -27,6 +27,7 @@ "discover_blog_id": 53424024, "features": { "code-splitting": true, + "server-side-rendering": true, "reader": true, "reader/teams": true, diff --git a/config/horizon.json b/config/horizon.json index 66b5fe1ee538d..c9199c3faa22e 100644 --- a/config/horizon.json +++ b/config/horizon.json @@ -13,6 +13,7 @@ "discover_blog_id": 53424024, "features": { "code-splitting": true, + "server-side-rendering": true, "post-editor": true, "post-editor/iframe-preview": true, diff --git a/config/production.json b/config/production.json index 3aa1a34fef918..b9f3e19b6afe1 100644 --- a/config/production.json +++ b/config/production.json @@ -11,6 +11,7 @@ "discover_blog_id": 53424024, "features": { "code-splitting": true, + "server-side-rendering": false, "manage/ads": true, "manage/ads/jetpack": true, "manage/customize": true, diff --git a/config/stage.json b/config/stage.json index 36f8b5b2de05f..c12fb8d995913 100644 --- a/config/stage.json +++ b/config/stage.json @@ -13,6 +13,7 @@ "discover_blog_id": 53424024, "features": { "code-splitting": true, + "server-side-rendering": false, "post-editor": true, "post-editor/iframe-preview": true, "post-editor/live-image-updates": true, diff --git a/config/wpcalypso.json b/config/wpcalypso.json index 9dc0386eeb6f1..4d3dc3b9f1ec7 100644 --- a/config/wpcalypso.json +++ b/config/wpcalypso.json @@ -13,6 +13,7 @@ "discover_blog_id": 53424024, "features": { "code-splitting": true, + "server-side-rendering": true, "post-editor": true, "post-editor/iframe-preview": true, diff --git a/server/pages/index.js b/server/pages/index.js index 8c560c6c4a14f..450c6b51a9ddf 100644 --- a/server/pages/index.js +++ b/server/pages/index.js @@ -375,11 +375,13 @@ module.exports = function() { } else { const context = getDefaultContext( req ); - try { - context.layout = ReactDomServer.renderToString( LayoutLoggedOutDesignFactory() ); - } catch ( ex ) { - if ( config( 'env' ) === 'development' ) { - throw ex; + if ( config.isEnabled( 'server-side-rendering' ) ) { + try { + context.layout = ReactDomServer.renderToString( LayoutLoggedOutDesignFactory() ); + } catch ( ex ) { + if ( config( 'env' ) === 'development' ) { + throw ex; + } } }