Skip to content

feat: read MUX_BASE_URL from env-file and persist to config#66

Merged
dylanjha merged 14 commits intomainfrom
claude/base-url-config
Apr 16, 2026
Merged

feat: read MUX_BASE_URL from env-file and persist to config#66
dylanjha merged 14 commits intomainfrom
claude/base-url-config

Conversation

@jrmann100
Copy link
Copy Markdown
Contributor

@jrmann100 jrmann100 commented Apr 16, 2026

Note

This was authored by @claude, not @jrmann100.

Summary

  • Parses MUX_BASE_URL from --env-file during mux login
  • If nonstandard (not https://api.mux.com), saves it as baseUrl in the environment's config.json
  • getMuxBaseUrl() now checks: env var > config > default, so subsequent commands use the configured base URL without needing the env var set
  • whoami displays API endpoint when using a nonstandard base URL

Test plan

  • All 699 existing + new tests pass
  • mux login --env-file with a .env containing MUX_BASE_URL=https://api.staging.mux.com saves baseUrl to config
  • mux login --env-file without MUX_BASE_URL does not add baseUrl to config
  • mux whoami uses the stored baseUrl without MUX_BASE_URL env var set
  • mux whoami shows API endpoint only when nonstandard

🤖 Generated with Claude Code


Note

Medium Risk
Changes how the CLI chooses the API endpoint and persists it to config, which can redirect all subsequent API calls for an environment if misconfigured; scope is contained and covered by new tests.

Overview
Adds support for a configurable Mux API endpoint: mux login --env-file now parses MUX_BASE_URL, validates credentials against that URL, and persists a non-default baseUrl into the saved environment config.

Updates base-URL resolution to prefer MUX_BASE_URL env var, then per-environment config, then the default; commands that fetch from the API (whoami, webhook listen, error permission probing) now use the resolved base URL, and whoami prints the active endpoint when non-default. Includes new/updated tests for .env parsing and getMuxBaseUrl precedence.

Reviewed by Cursor Bugbot for commit 0017213. Bugbot is set up for automated code reviews on this repo. Configure here.

@jrmann100
Copy link
Copy Markdown
Contributor Author

@cursor review if you would be so kind?

Comment thread src/lib/mux.ts Outdated
@dylanjha dylanjha marked this pull request as ready for review April 16, 2026 21:40
Comment thread src/commands/login.ts
Comment thread src/commands/login.ts Outdated
Comment thread src/lib/mux.ts Outdated
jrmann100 and others added 6 commits April 16, 2026 15:31
When logging in with --env-file, MUX_BASE_URL is now parsed and, if
nonstandard, saved to the environment's config.json. getMuxBaseUrl()
checks env var > config > default, so subsequent commands automatically
use the configured base URL without needing the env var set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
createAuthenticatedMuxClient() was not forwarding the configured
base URL to the SDK, so SDK-based commands always hit the default
api.mux.com regardless of config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents stale config baseUrl from being used when logging in
without MUX_BASE_URL set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nfig read

- Login now checks env-file > process.env.MUX_BASE_URL > default,
  so interactive login with MUX_BASE_URL set works correctly.
- createAuthenticatedMuxClient reads baseUrl from the already-fetched
  environment instead of calling getMuxBaseUrl() (which would re-read
  config from disk).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jrmann100 jrmann100 force-pushed the claude/base-url-config branch from d928d0d to 404770f Compare April 16, 2026 22:32
Comment thread src/lib/mux.ts Outdated
jrmann100 and others added 2 commits April 16, 2026 15:38
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/commands/webhooks/listen.ts Outdated
jrmann100 and others added 3 commits April 16, 2026 15:51
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nfig read

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e635ada. Configure here.

Comment thread src/commands/whoami.ts Outdated
jrmann100 and others added 3 commits April 16, 2026 16:02
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… wrapper

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dylanjha dylanjha merged commit 03c3585 into main Apr 16, 2026
7 of 8 checks passed
@dylanjha dylanjha deleted the claude/base-url-config branch April 16, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants