Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event.context.nitro in undefined in CF pages #2531

Open
farnabaz opened this issue Jun 14, 2024 · 0 comments
Open

event.context.nitro in undefined in CF pages #2531

farnabaz opened this issue Jun 14, 2024 · 0 comments

Comments

@farnabaz
Copy link
Contributor

farnabaz commented Jun 14, 2024

Environment

- Operating System: Darwin
- Node Version:     v20.11.1
- Nuxt Version:     3.12.1
- CLI Version:      3.12.0
- Nitro Version:    2.10.0-28638494.93d002b7
- Package Manager:  [email protected]

Reproduction

Live: https://7b85d7f1.nuxthub.pages.dev/
Faced on https://github.com/nuxt-hub/platform/pull/203

Describe the bug

Deploying project to Cloudflare pages result undefined error because event.context.nitro is undefined.

I made a little patch that handles the undefined error. This might not be the correct solution for this issue but as a workaround it works fine

diff --git a/dist/runtime/internal/config.mjs b/dist/runtime/internal/config.mjs
index f4314c748192ce0fe2fd72bb61de28fa8b70f1eb..c8c508297723568bbc1b817b14c89f1d691868a7 100644
--- a/dist/runtime/internal/config.mjs
+++ b/dist/runtime/internal/config.mjs
@@ -14,11 +14,12 @@ export function useRuntimeConfig(event) {
   if (!event) {
     return _sharedRuntimeConfig;
   }
-  if (event.context.nitro.runtimeConfig) {
+  if (event.context.nitro?.runtimeConfig) {
     return event.context.nitro.runtimeConfig;
   }
   const runtimeConfig = klona(_inlineRuntimeConfig);
   applyEnv(runtimeConfig, envOptions);
+  event.context.nitro = event.context.nitro || {};
   event.context.nitro.runtimeConfig = runtimeConfig;
   return runtimeConfig;
 }

Additional context

No response

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant