Skip to content

5.9 - A missing NEXT_PUBLIC_API_URL silently targets the visitor's own machine #155

Description

@determined-001

Complexity: Trivial - 100 Points · type:dx

Milestone: M4 - Merchant surface

Band lever: none

Context
apps/web/lib/api.ts:76 reads
process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8787". The fallback is
right for local development and wrong everywhere else.

Problem
NEXT_PUBLIC_* values are baked at build time, so forgetting this variable on a
deployed build is not caught by anything at deploy time. Every dashboard request
then targets localhost:8787 in the visitor's browser — connection refused,
with no error message naming the real cause. docs/MAINNET.md already calls out
this exact class of footgun for NEXT_PUBLIC_STELLAR_NETWORK; this variable has
the same failure mode and no such note.

What needs to be done

  1. Keep the localhost fallback only when process.env.NODE_ENV !== "production".
  2. In a production build with the variable unset, fail loudly — throw at module
    load, or render a clear configuration error rather than issuing doomed
    requests.
  3. Document the variable alongside NEXT_PUBLIC_STELLAR_NETWORK in
    docs/MAINNET.md and .env.public.example, with the same "rebuild after
    changing" warning.

Key files

  • apps/web/lib/api.ts:76BROWSER_BASE
  • docs/MAINNET.md — the existing NEXT_PUBLIC_* footgun section
  • .env.public.example

Done when

  • A production build with the variable unset fails with a message naming it.
  • Local development is unaffected.

Tracked in ISSUES.md — issue 5.9.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveDrips Wave Program - opt an issue in by applying this labelarea:webapps/web - dashboard, checkout, widgetcomplexity:trivial100 pointsgood-first-issueSelf-contained, well-scoped, safe for newcomerstype:dx

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions