From: Dessalines Date: Fri, 11 Sep 2020 04:03:01 +0000 (-0500) Subject: Inferno helmet SSR. X-Git-Url: http://these/git/%22https:/www.exeterceilidhs.net/%22%7B%7D/README.zh.hans.md?a=commitdiff_plain;h=d909ec80968d85150d7534e80b1f36500eb4547c;p=lemmy-ui.git Inferno helmet SSR. --- diff --git a/src/server/index.tsx b/src/server/index.tsx index 26771e2..ce89a7f 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 e36f819..74b181b 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') {