fix(config): apply $production/$development layers when NODE_ENV is unset#4066
fix(config): apply $production/$development layers when NODE_ENV is unset#4066jlgrimes wants to merge 1 commit intonitrojs:mainfrom
Conversation
|
@jlgrimes is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe changes introduce an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/unit/config-loader-env.test.ts (1)
60-61: Consider verifying base layer is preserved alongside env layer.The fixture defines a base
/baseroute. Adding an assertion for it would confirm that env-specific layers are merged correctly without losing base configuration.💡 Optional enhancement
expect(options.routeRules["/prod"]?.headers?.["x-env"]).toBe("production"); expect(options.routeRules["/dev"]).toBeUndefined(); + expect(options.routeRules["/base"]?.headers?.["x-env"]).toBe("base"); }); it("applies $development when NODE_ENV is unset and dev=true", async () => { // ... expect(options.routeRules["/dev"]?.headers?.["x-env"]).toBe("development"); expect(options.routeRules["/prod"]).toBeUndefined(); + expect(options.routeRules["/base"]?.headers?.["x-env"]).toBe("base"); });Also applies to: 71-72
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/unit/config-loader-env.test.ts` around lines 60 - 61, Add assertions that the base route from the fixture is still present after env layering: check options.routeRules["/base"] exists and its original properties (e.g., headers, upstreams, or whatever the fixture defines) match expected values to ensure the env layer merged rather than replaced the base layer; update both places where routeRules for env tests are asserted (the blocks that currently check "/prod"/"/dev") to include these "/base" assertions referencing options.routeRules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/unit/config-loader-env.test.ts`:
- Around line 60-61: Add assertions that the base route from the fixture is
still present after env layering: check options.routeRules["/base"] exists and
its original properties (e.g., headers, upstreams, or whatever the fixture
defines) match expected values to ensure the env layer merged rather than
replaced the base layer; update both places where routeRules for env tests are
asserted (the blocks that currently check "/prod"/"/dev") to include these
"/base" assertions referencing options.routeRules.
🔗 Linked issue
Resolves #3052
❓ Type of change
📚 Description
Nitro uses c12 for config loading, but when NODE_ENV is unset it currently forwards no envName, so c12 skips $production and $development layers entirely.
This causes production deployments (e.g. Cloudflare Pages) to ignore $production config blocks unless NODE_ENV is manually set.
What changed
Validation