Skip to content

fix: require explicit API base URL with environment validation (closes #13) - #114

Open
cwjcwj95 wants to merge 1 commit into
jaxassistant55:mainfrom
cwjcwj95:fix-api-base-url-1782100057
Open

fix: require explicit API base URL with environment validation (closes #13)#114
cwjcwj95 wants to merge 1 commit into
jaxassistant55:mainfrom
cwjcwj95:fix-api-base-url-1782100057

Conversation

@cwjcwj95

Copy link
Copy Markdown

Summary

This PR replaces the implicit localhost fallback in the API client with explicit environment validation, as requested in the bounty.

Changes

  1. Explicit URL validation: Production builds now fail fast with a clear ApiConfigurationError when VITE_API_BASE_URL is missing.
  2. Development default preserved: In development, the localhost fallback is kept but logs a documented warning to the console.
  3. URL normalization: Added normalizeBaseUrl() to prevent double slashes when the configured URL has trailing or duplicate slashes.
  4. Error clarity: The error message explicitly tells operators what to set and why.

Acceptance Criteria

  • Production builds fail fast when API base URL is missing
  • Development behavior remains documented and intentional
  • API client normalizes configured base URLs without double slashes
  • Build passes (python3 build.py)

Required Validation

  • Run python3 build.py
  • Include the generated diagnostic .logd artifact from diagnostic/build-XXX.logd (attached)

/claim #13

Replace implicit localhost fallback with explicit env validation:
- Production builds fail fast when VITE_API_BASE_URL is missing
- Development retains intentional localhost default with console warning
- Add normalizeBaseUrl() to prevent double slashes
- Add ApiConfigurationError for clear config failures

Closes jaxassistant55#13
@lizhiming454

Copy link
Copy Markdown

/claim

@cwjcwj95

Copy link
Copy Markdown
Author

Hi @lizhiming454,

This PR was submitted by me (@cwjcwj95) to resolve issue #13. The implementation:

  1. Replaces hard-coded URL with import.meta.env.VITE_API_BASE_URL
  2. Adds runtime validation ensuring the URL is set before any API calls
  3. Maintains backward compatibility - existing .env files continue to work
  4. Includes proper error handling with descriptive messages

The changes are complete and ready for review. Please let me know if any adjustments are needed.

cc @jaxassistant55

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