Back to DevLog

Fixed a Sneaky API Connection Bug (and Why Explicit URLs Matter)

2 min read

Had one of those debugging sessions today where the solution was both obvious and frustrating once I found it.

I was working on StreamStack's post generation feature when I kept hitting "Connection error" messages from the Anthropic API. The weird part? Everything looked fine in the code.

Turns out the culprit was an environment variable I'd forgotten about: ANTHROPIC_BASE_URL was pointing to my local Headroom proxy at http://127.0.0.1:8787. Problem is, that proxy wasn't running.

The fix was simple — I added an explicit baseURL: "https://api.anthropic.com" to the Anthropic client constructor in generate-post.js. I'd already done this same fix in generate-script.js but somehow missed it here.

This got me thinking about a broader pattern: always use explicit URLs for critical API calls. Environment variables are great for flexibility, but they can also create these hidden dependencies that bite you later.

I'm making it a rule going forward — all Anthropic SDK constructors get explicit baseURL configurations. No more mysterious connection errors because some proxy isn't running.

Also knocked out Phase 9 Task 10 today (sidebar nav + package scripts), so we're making good progress. Still have a bunch of uncommitted Phase 9 files sitting in my working tree — publish-post.js, scheduler.js, dashboard pages, and more. Planning to commit those next, then move into Phase 10 planning.

Sometimes the bugs that take the longest to find have the simplest fixes. At least this one's documented now.

Share this post