fix: missing open tags in production

pull/1/head
Antonio De Lucreziis 2 years ago
parent 1deea11126
commit 2dfce9d7d7

@ -26,6 +26,8 @@ export const App = ({ url }: { url?: string }) => {
// during server side rendering don't prepend the BASE_URL
const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl
console.log(url)
return (
<Router url={url}>
<HomePage

@ -97,7 +97,23 @@ async function createProductionRouter() {
const { html, metadata } = render(req.originalUrl)
res.send(transformedTemplate.replace('<!-- SSR OUTLET -->', html))
process.stdout.write('[Metadata] ')
console.dir(metadata)
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
const metaTagsHtml =
'' +
(metadata.title ? `<meta property="og:title" content="${metadata.title}" />\n` : '') +
(metadata.description
? `<meta property="og:description" content="${metadata.description}" />\n`
: '') +
`<meta property="og:url" content="${fullUrl}" />\n`
res.send(
transformedTemplate
.replace('<!-- INJECT META TAGS -->', metaTagsHtml)
.replace('<!-- SSR OUTLET -->', html)
)
})
return r

Loading…
Cancel
Save