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

Cloudflare: Environment variables starting with NITRO_ are not passed to runtimeConfig #2468

Open
MickL opened this issue May 24, 2024 · 3 comments

Comments

@MickL
Copy link
Contributor

MickL commented May 24, 2024

Environment

nitropack: 2.9.6

Reproduction

Describe the bug

Environment variables dont seem to work on Cloudflare:

export default defineNitroConfig({
  runtimeConfig: {
    myVar: ''
  },
});

This works locally with .env:

NITRO_MY_VAR="Hello world"

But deployed to Cloudflare with the environment set in Cloudflare Dashboard it stays empty. Using the following workaround it works:

  runtimeConfig: {
    myVar: process.env.NITRO_MY_VAR,
  },

But what would then the purpose of defining NITRO_ env vars in the first place when they are not auto "injected"?

Additional context

No response

Logs

No response

@pi0
Copy link
Member

pi0 commented May 27, 2024

Do you call runtimeConfig(event) inside an event handler? Due to how late cloudflare provides environment (during request) it is a limitation.

@MickL
Copy link
Contributor Author

MickL commented May 27, 2024

I do not. It works with the example above so in nuxt/nitro config the process env is there?

@te1
Copy link

te1 commented Jun 2, 2024

See also https://github.com/Atinux/nuxt-env-repro which gives this output (called from inside an event handler):

{
  "runtimeConfig().hello": "",
  "runtimeConfig(event).hello": "world",
  "process.env.NUXT_HELLO": "world"
}

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

3 participants