nitrojs / nitrojs/nitro

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

Open
#2,468 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from defineNitroConfig runtimeConfig handling and compare local .env loading with process.env.NITRO_MY_VAR when deployed to Cloudflare. Reproduce with nitropack 2.9.6 and a dashboard-defined NITRO_MY_VAR; done means the runtimeConfig value is populated without the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.