Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
devknoll committed Jul 20, 2021
1 parent 5ced755 commit a67554d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/next/server/next-server.ts
Expand Up @@ -1335,11 +1335,13 @@ export default class Server {
query: ParsedUrlQuery
}
): Promise<void> {
// TODO: Determine when dynamic HTML is allowed
const requireStaticHTML = true
const ctx = {
...partialContext,
renderOpts: {
...this.renderOpts,
requireStaticHTML: false,
requireStaticHTML,
},
} as const
const payload = await fn(ctx)
Expand All @@ -1357,7 +1359,9 @@ export default class Server {
return sendRenderResult({
req,
res,
resultOrPayload: body,
resultOrPayload: requireStaticHTML
? (await resultToChunks(body)).join('')
: body,
type,
generateEtags,
poweredByHeader,
Expand Down
6 changes: 4 additions & 2 deletions packages/next/server/send-payload.ts
Expand Up @@ -112,8 +112,10 @@ export function sendRenderResult({
setRevalidateHeaders(res, options)
}

if (isPayload) {
res.end(req.method === 'HEAD' ? null : (resultOrPayload as string))
if (req.method === 'HEAD') {
res.end(null)
} else if (isPayload) {
res.end(resultOrPayload as string)
} else {
;(resultOrPayload as RenderResult)({
next: (chunk) => res.write(chunk),
Expand Down

0 comments on commit a67554d

Please sign in to comment.