Skip to content

fix: security proxy prefers raw runtimeConfig/process.env strings over coerced values - #1420

Merged
yamcodes merged 7 commits into
devfrom
1327-fixnuxt-security-proxy-prefers-raw-runtimeconfigprocessenv-strings-over-coerced-values
Jul 20, 2026
Merged

fix: security proxy prefers raw runtimeConfig/process.env strings over coerced values#1420
yamcodes merged 7 commits into
devfrom
1327-fixnuxt-security-proxy-prefers-raw-runtimeconfigprocessenv-strings-over-coerced-values

Conversation

@yamcodes

Copy link
Copy Markdown
Owner

Fixes #1327

Summary

  • Prefer the coerced validation target in the Nuxt security proxy instead of re-reading raw useRuntimeConfig() / process.env / __NUXT__.config.public strings (which silently undid ADR 0002 coercion).
  • Update dynamic useRuntimeConfig tests to assert coerced number/boolean values, and add regression coverage for the server process.env and client __NUXT__ paths.
  • Add a missing @arkenv/nuxt Vitest project config so the package tests run in CI.

Test plan

  • pnpm exec vitest run --project @arkenv/nuxt
  • pnpm run typecheck
  • pnpm run test
  • pnpm run fix

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@yamcodes yamcodes added the bug Something isn't working label Jul 20, 2026
@yamcodes yamcodes added tests This issue or PR is about adding, removing or changing tests @arkenv/nuxt Issues or Pull Requests involving the Nuxt integration for ArkEnv labels Jul 20, 2026
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eef5902

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@arkenv/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the docs Adds or changes documentation, or acts as documentation in and of itself label Jul 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

arkenv

npm i https://pkg.pr.new/arkenv@1420

@arkenv/build

npm i https://pkg.pr.new/@arkenv/build@1420

@arkenv/bun-plugin

npm i https://pkg.pr.new/@arkenv/bun-plugin@1420

@arkenv/cli

npm i https://pkg.pr.new/@arkenv/cli@1420

@arkenv/fumadocs-ui

npm i https://pkg.pr.new/@arkenv/fumadocs-ui@1420

@arkenv/nextjs

npm i https://pkg.pr.new/@arkenv/nextjs@1420

@arkenv/nuxt

npm i https://pkg.pr.new/@arkenv/nuxt@1420

@arkenv/vite-plugin

npm i https://pkg.pr.new/@arkenv/vite-plugin@1420

commit: 1a12d37

@arkenv-bot

arkenv-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

No results found

All size limits passed!

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the PR fixes the Nuxt security proxy so schema-key reads always return the coerced validation target, and adds regression coverage plus the missing Vitest project config.

  • packages/nuxt/src/create-env.ts — removes the per-get runtimeConfig/process.env/__NUXT__ preference branches from createSecurityProxy.
  • packages/nuxt/src/index.test.ts — updates dynamic config tests to assert coerced number/boolean values and adds tests for the server process.env and client __NUXT__ paths.
  • packages/nuxt/src/mock-imports.ts — extracts the useRuntimeConfig test mock so #imports resolves cleanly.
  • packages/nuxt/vitest.config.ts — adds the project config required for CI discovery.
  • .changeset/fix-nuxt-proxy-coercion.md — patch changeset for @arkenv/nuxt.

I built the required workspace dependencies (@repo/scope, @repo/types, @arkenv/build, arkenv) and verified:

  • pnpm exec vitest run --project @arkenv/nuxt — 28 tests passed.
  • pnpm --filter @arkenv/nuxt typecheck — clean.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

yamcodes and others added 2 commits July 21, 2026 00:40
Keep coerced types when reading from env to ensure number and boolean keys return their respective types at runtime.
Drop "dynamically resolve" / "fallback path" wording that described the
old get-time re-read of raw runtimeConfig/process.env strings.

Co-authored-by: Yam Borodetsky <hi@yam.codes>
@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown

Follow-up: renamed the coercion regression tests so they no longer say “dynamically resolve” / “fallback path” (that described the old get-time re-read of raw strings). They now describe create-time sourcing through the proxy.

Suggested PR body note (couldn’t edit the description from this agent):

The previous suite only asserted string keys on the useRuntimeConfig / process.env / __NUXT__ paths, so CI could not catch this bug. Boot-time NUXT_PUBLIC_* override honesty and a validator-free client env remain in #1424 (v1).

Comment thread .changeset/fix-nuxt-proxy-coercion.md
Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
Comment thread .changeset/fix-nuxt-proxy-coercion.md Outdated
Comment thread packages/nuxt/src/create-env.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The latest changeset edits still leave the ts code block unclosed, which will break the changeset/changelog render.

Reviewed changes — The new commits since df2c3a5a only touched .changeset/fix-nuxt-proxy-coercion.md; they tightened the description but did not add the missing closing fence.

  • Updated .changeset/fix-nuxt-proxy-coercion.md — clarified that coerced number/boolean values are returned at runtime.
  • Merged current dev — brought the branch up to date with no semantic conflicts.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread .changeset/fix-nuxt-proxy-coercion.md
Updated NUXT_PUBLIC_PORT and PORT to use number type.
@yamcodes
yamcodes merged commit aecac94 into dev Jul 20, 2026
19 checks passed
@yamcodes
yamcodes deleted the 1327-fixnuxt-security-proxy-prefers-raw-runtimeconfigprocessenv-strings-over-coerced-values branch July 20, 2026 20:07
@arkenv-bot arkenv-bot Bot mentioned this pull request Jul 20, 2026
yamcodes pushed a commit that referenced this pull request Jul 20, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to dev, this PR will
be updated.


# Releases
## @arkenv/cli@0.5.1

### Patch Changes

- #### Add `add host` command to CLI for adding hosting presets to
existing schemas
_[`#1324`](#1324)
[`eed3cce`](eed3cce)
[@abhimanyutiwaribot](https://github.com/abhimanyutiwaribot)_

Support adding a hosting provider preset (Vercel or Netlify) to an
existing `env.ts` configuration file:

  ```bash
  npx @arkenv/cli@latest add host [provider]
  ```

- Prompts interactively to select Vercel or Netlify if the provider is
omitted.
- Auto-detects the framework (Next.js, Nuxt, Vite, Bun) and the
validator engine (Zod, Valibot, or ArkType) to inject the preset fields
with the correct syntax.
- Fallback to logging the generated variable schemas to stdout with
manual configuration instructions if `env.ts` is missing or unparseable.
## @arkenv/nuxt@0.0.7

### Patch Changes

- #### Fix number and boolean env values returning as strings
_[`#1420`](#1420)
[`aecac94`](aecac94)
[@yamcodes](https://github.com/yamcodes)_

Keep coerced types when reading from `env`. A key declared as `"number"`
or `"boolean"` now returns a number or boolean at runtime, not the raw
string from Nuxt runtime config.

  ```ts
  import { createEnv } from "@arkenv/nuxt";

  export const env = createEnv({
    NUXT_PUBLIC_PORT: "number",
    PORT: "number",
  });

  // Was "3000" (string) — now 3000 (number)
  env.NUXT_PUBLIC_PORT;
  env.PORT;
  ```

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
yamcodes added a commit that referenced this pull request Jul 20, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary
- Forward-ports [#1420](#1420) /
[#1327](#1327) from `dev` onto
`v1`
- On `v1`, `createSecurityProxy` in `arkenv-internal.ts` already
preferred the coerced validation target (the get-time `runtimeConfig` /
`process.env` / `__NUXT__` preference bug never landed here). This port
locks that invariant with ADR 0015 docs comments and coercion regression
tests.
- Adds a `patch` changeset for `@arkenv/nuxt` (v1+ bump rules)

## Notes
- Skipped the `useRuntimeConfig` create-time tests from #1420: `v1`
`arkenvInternal` does not merge `useRuntimeConfig()` into `sourceEnv`
(server uses `process.env`; client uses `__NUXT__` / `process.env`).
- Boot-time `NUXT_PUBLIC_*` payload honesty / validator-free client
remain #1424.

## Test plan
- [x] `pnpm --filter @arkenv/nuxt exec vitest run src/index.test.ts` (7
passed)
- [x] `pnpm --filter @arkenv/nuxt typecheck`

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-0623c244-7bc7-41d8-8d5f-7445513461e0"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-0623c244-7bc7-41d8-8d5f-7445513461e0"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@arkenv/nuxt Issues or Pull Requests involving the Nuxt integration for ArkEnv bug Something isn't working docs Adds or changes documentation, or acts as documentation in and of itself tests This issue or PR is about adding, removing or changing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(nuxt): security proxy prefers raw runtimeConfig/process.env strings over coerced values

2 participants