Skip to content

fix(examples/ts): align custom client env vars with .env-local#2341

Merged
phdargen merged 1 commit into
x402-foundation:mainfrom
feldmannn:fix/custom-example-env-vars
May 17, 2026
Merged

fix(examples/ts): align custom client env vars with .env-local#2341
phdargen merged 1 commit into
x402-foundation:mainfrom
feldmannn:fix/custom-example-env-vars

Conversation

@feldmannn
Copy link
Copy Markdown
Contributor

Description

The TypeScript custom client example at examples/typescript/clients/custom/index.ts reads process.env.SERVER_URL (which is not declared in this example's .env-local) and hardcodes the path /weather. As a result, developers following the .env-local template see no effect from their edits: the env-var fallback http://localhost:4021 always wins, and the path is unconfigurable despite .env-local providing ENDPOINT_PATH.

Every other client example in the same directory (fetch/, axios/) already uses the canonical three-line pattern. This PR aligns the custom client with that pattern:

const baseURL = process.env.RESOURCE_SERVER_URL || "http://localhost:4021";
const endpointPath = process.env.ENDPOINT_PATH || "/weather";
const url = `${baseURL}${endpointPath}`;

The new three-line block is byte-identical to examples/typescript/clients/fetch/index.ts:15-17 and examples/typescript/clients/axios/index.ts:16-18. No other changes to the file, the example README, or .env-local.

Disclosure: this change was prepared with the help of an AI coding assistant. The diff was independently reviewed and verified line-for-line against the canonical sibling pattern before commit.

Tests

There are no tests in examples/typescript/clients/custom/ (it ships as a runnable tsx example, not a build target). Local verification performed against main:

  • pnpm install from examples/typescript/: exit 0
  • pnpm-lock.yaml diff vs main: empty (passes check_package_lock.yml)
  • Prettier check on the changed file (LF line endings, matching Linux CI): clean
  • ESLint on the changed file (LF line endings): clean
  • Byte-for-byte equality of the new 3-line block against fetch/index.ts:15-17 and axios/index.ts:16-18: confirmed

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
  • I added a changelog fragment for user-facing changes (skipped: examples are not published as a package)

The custom client example referenced process.env.SERVER_URL (undefined in
.env-local) and hardcoded /weather, silently falling back to the localhost
default. Align with the canonical pattern used by the fetch and axios
client examples.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

@feldmannn is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the examples Changes to examples label May 17, 2026
Copy link
Copy Markdown
Collaborator

@phdargen phdargen left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @feldmannn

@phdargen phdargen self-assigned this May 17, 2026
@phdargen phdargen merged commit 031434f into x402-foundation:main May 17, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Changes to examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants