From d909ec80968d85150d7534e80b1f36500eb4547c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 10 Sep 2020 23:03:01 -0500 Subject: [PATCH] Inferno helmet SSR. --- src/server/index.tsx | 14 +++++++++++--- webpack.config.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 26771e2c..ce89a7fa 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -12,6 +12,7 @@ import IsomorphicCookie from 'isomorphic-cookie'; import { lemmyHttp, setAuth } from '../shared/utils'; import { GetSiteForm, GetSiteResponse } from 'lemmy-js-client'; import process from 'process'; +import { Helmet } from 'inferno-helmet'; const server = express(); const port = 1234; @@ -65,12 +66,19 @@ server.get('/*', async (req, res) => { return res.redirect(context.url); } + const root = renderToString(wrapper); + const helmet = Helmet.renderStatic(); + res.send(` - + + ${helmet.title.toString()} + ${helmet.meta.toString()} + ${helmet.link.toString()} + @@ -89,14 +97,14 @@ server.get('/*', async (req, res) => { - + -
${renderToString(wrapper)}
+
${root}
diff --git a/webpack.config.js b/webpack.config.js index e36f8190..74b181b3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -49,7 +49,7 @@ module.exports = function (env, _) { // server-specific configuration if (env.platform === 'server') { base.target = 'node'; - base.externals = [nodeExternals()]; + base.externals = [nodeExternals(), 'inferno-helmet']; } // client-specific configurations if (env.platform === 'client') {