Skip to content

fix: make API URL configurable + add timeout + proper error handling (fixes #5)#6

Open
D2758695161 wants to merge 1 commit into
wangtsiao:mainfrom
D2758695161:main
Open

fix: make API URL configurable + add timeout + proper error handling (fixes #5)#6
D2758695161 wants to merge 1 commit into
wangtsiao:mainfrom
D2758695161:main

Conversation

@D2758695161
Copy link
Copy Markdown

Summary

Fixes wangtsiao/pulse-cn-mcp#5 — "Fetch Failed"

Problem

When api.vvhan.com is inaccessible or slow, all tools fail with unhelpful error messages. The hardcoded API URL provides no way to use alternative endpoints.

Solution

  1. Configurable API URL via VVHAN_API_URL environment variable:

    VVHAN_API_URL=https://your-mirror.com/api npx pulse-cn-mcp
  2. Fetch timeout (default 8s, configurable via VVHAN_TIMEOUT_MS):

    VVHAN_TIMEOUT_MS=5000 npx pulse-cn-mcp
  3. Better error messages for debugging:

    • Timeout errors now show which URL timed out
    • HTTP errors show status code

Files changed

  • src/utils/fetch.ts — core fetch utility

Testing

# Test with custom API
VVHAN_API_URL=https://custom.api.com/api npx pulse-cn-mcp

# Test with shorter timeout
VVHAN_TIMEOUT_MS=3000 npx pulse-cn-mcp

Fixes wangtsiao#5 - Fetch Failed error

Changes:
- API base URL now configurable via VVHAN_API_URL env var
- Added fetch timeout (default 8s, configurable via VVHAN_TIMEOUT_MS)
- Better error messages for debugging
- Falls back gracefully on network errors
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.

Fetch Failed

1 participant