Commit 5d967409 authored by Evan You's avatar Evan You Committed by GitHub

Merge pull request #66 from rumkin/patch-1

Update server.js
parents 9f6bceb8 1cefd6c8
......@@ -59,10 +59,10 @@ app.get('*', (req, res) => {
var s = Date.now()
const context = { url: req.url }
const renderStream = renderer.renderToStream(context)
let firstChunk = true
renderStream.on('data', chunk => {
if (firstChunk) {
// Write head once
renderStream.once('data', () => {
res.write(html.head)
// embed initial store state
if (context.initialState) {
......@@ -72,8 +72,9 @@ app.get('*', (req, res) => {
}</script>`
)
}
firstChunk = false
}
})
renderStream.on('data', chunk => {
res.write(chunk)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment