[Feature Request] server-only environment variables should not be sent to client

Open
#1,254 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@theoephraim is already working on this.

Since Nov 3, 2026.

  • #1274 by @theoephraim — open

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend, security

Research direction

Start by tracing how /api/public-env selects variables and how the @public, @dynamic, and @sensitive markers are defined and applied. The issue does not name implementation files or tests, so locate the endpoint and its coverage first. Done means only variables explicitly marked for client exposure are returned, with build-time and runtime behavior covered.

Written by the indexing model from the issue text.

Description

enhancement
Description

documentation say /api/public-env expose only environment variables marked with @public and @dynamic

But it actually exposing some serve-side only environment variables marked with @sensitive=false and @dynamic. This might be a security risk.

<script>
globalThis.__varlockPublicDynamicEnv={
  "FF_ENABLE_DARK_MODE":false,
  "BETTER_AUTH_URL":"http://localhost:3000",
  "TURNSTILE_SITE_KEY":"1x00000000000000000000AA"};
   ...
globalThis.__varlockPublicDynamicEnvEndpoint="/api/public-env";
</script>
Motivation

I want only expose some environment variables that are changeable at runtime (@public and @dynamic)
don't want to expose all non-sensitive server-only variables.

Proposed Solution

please provide 3 dimensions of markers for env variables

  1. client-side: true/false (whether they should exposed to browser - either at build-time or run-time)
  2. dynamic: true/false (build-time inject vs run-time inject)
  3. sensitive: true/false (secrets or non-secrets)
Alternatives

No response

Additional Information

No response

Dominant language
TypeScript
Stars
4.9k
Forks
140
Avg merge
2d 3h
Merged PRs (30d)
35

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from dmno-dev/varlock

All issues in dmno-dev/varlock

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.