Skip to content

Commit 049d01c

Browse files
Apply suggestions from code review
Co-authored-by: Victor Berchet <[email protected]>
1 parent d4a5d4b commit 049d01c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

examples/ssg-app/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default async function Home() {
99
return (
1010
<div className={styles.page}>
1111
<main className={styles.main}>
12-
<h1>Hello from a Statically generated app</h1>
12+
<h1>Hello from a Statically generated page</h1>
1313
<p data-testid="my-secret">{cloudflareContext.env.MY_SECRET}</p>
1414
</main>
1515
</div>

packages/cloudflare/src/api/cloudflare-context.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ export function getCloudflareContext<
8080
const asyncMode = options.async;
8181

8282
if (!cloudflareContext) {
83-
// The non-async mode of `getCloudflareContext`, relies on the context set on the global state
83+
// The sync mode of `getCloudflareContext`, relies on the context being set on the global state
8484
// by either the worker entrypoint (in prod) or by `initOpenNextCloudflareForDev` (in dev), neither
8585
// can work during SSG since for SSG Next.js creates (jest) workers that don't get access to the
86-
// normal global state. There isn't much we can do about this so we can only throw with a helpful
87-
// error message for the user.
88-
// Note: Next.js sets globalThis.__NEXT_DATA__.nextExport to true for SSG routes, so we can use that to detect
89-
// wether the route is being SSG'd (source: https://github.com/vercel/next.js/blob/4e394608423/packages/next/src/export/worker.ts#L55-L57)
86+
// normal global state so we throw with a helpful error message.
87+
// Note: Next.js sets globalThis.__NEXT_DATA__.nextExport to true for SSG routes
88+
// source: https://github.com/vercel/next.js/blob/4e394608423/packages/next/src/export/worker.ts#L55-L57)
9089
if (!asyncMode && global.__NEXT_DATA__?.nextExport === true) {
9190
throw new Error(
9291
`\n\nERROR: \`getCloudflareContext\` has been called in a static route` +

0 commit comments

Comments
 (0)