File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
packages/cloudflare/src/api Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export default async function Home() {
9
9
return (
10
10
< div className = { styles . page } >
11
11
< main className = { styles . main } >
12
- < h1 > Hello from a Statically generated app </ h1 >
12
+ < h1 > Hello from a Statically generated page </ h1 >
13
13
< p data-testid = "my-secret" > { cloudflareContext . env . MY_SECRET } </ p >
14
14
</ main >
15
15
</ div >
Original file line number Diff line number Diff line change @@ -80,13 +80,12 @@ export function getCloudflareContext<
80
80
const asyncMode = options . async ;
81
81
82
82
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
84
84
// by either the worker entrypoint (in prod) or by `initOpenNextCloudflareForDev` (in dev), neither
85
85
// 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)
90
89
if ( ! asyncMode && global . __NEXT_DATA__ ?. nextExport === true ) {
91
90
throw new Error (
92
91
`\n\nERROR: \`getCloudflareContext\` has been called in a static route` +
You can’t perform that action at this time.
0 commit comments