Skip to content

Instantly share code, notes, and snippets.

View hcentelles's full-sized avatar

Hiram Centelles Rodríguez hcentelles

View GitHub Profile

prompt

This file contains all the files in the repository combined into one. The @opennextjs/cloudflare adapter lets you deploy Next.js apps to Cloudflare Workers using the Node.js "runtime" from Next.js. I'having a issue: When the Page Router next/head component is used on (SSR) pages using getServerSideProps() the html that came from the server did not have the meta tags that the component next/head should add. The meta tags are added later (on hydration phase I suppose), if I inspect the page in the devtools Elements tab I can verify it. Can you find what part of the code is causing this bug? On static pages it works ok.

response

prompt

here you have the @opennextjs/aws code as a single file so you can look into it to catch the bug

response

Okay, I've analyzed the @opennextjs/aws codebase provided, focusing on the interaction between SSR (getServerSideProps), next/head, and the adapter's response handling, especially streaming.

Based on the code and the described behavior (works for SSG, fails for SSR initial response), the most likely cause lies in the timing of when the HTTP headers and the initial HTML section are flushed relative to when Next.js finalizes the content collected from next/head components during a streaming SSR render.

Here's a breakdown of the relevant parts and the probable issue: