Skip to content

Commit

Permalink
Merge pull request #149 from sebringrose/hotfixes
Browse files Browse the repository at this point in the history
fix: seperate hash/response in ssrHandler
  • Loading branch information
sejori authored Mar 26, 2023
2 parents b728e26 + 123daf1 commit e4819ba
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions handlers/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ export const ssrHandler = (render: Render, opts: ssrHandlerOptions = {}): Handle
if (!opts.crypto) {
opts.crypto = new Crypto(crypto.randomUUID())
}

const HTML = await render(ctx)
const hashString = await opts.crypto.hash(HTML)

const hashString = await opts.crypto.hash(await render(ctx))
const headers = new Headers({
"Content-Type": "text/html; charset=utf-8",
"ETag": hashString
})
if (opts.headers) mergeHeaders(headers, opts.headers)

return new Response(HTML, { headers })
return new Response(await render(ctx), { headers })
}

0 comments on commit e4819ba

Please sign in to comment.