Skip to content

pass user agent and allow response.status 2xx#199

Open
PatrickSteil wants to merge 1 commit into
BlinkTagInc:masterfrom
PatrickSteil:master
Open

pass user agent and allow response.status 2xx#199
PatrickSteil wants to merge 1 commit into
BlinkTagInc:masterfrom
PatrickSteil:master

Conversation

@PatrickSteil
Copy link
Copy Markdown

@PatrickSteil PatrickSteil commented May 16, 2026

Fix GTFS URL download failures

Some GTFS URLs that work fine in a browser would fail silently when downloaded by node-gtfs. Two bugs in downloadGtfsFiles were responsible:

1. Missing User-Agent header
Node's fetch sends no User-Agent by default. Many transit agency servers (especially government ones) block or reject requests without one, while browsers succeed because they always identify themselves. A default User-Agent: node-gtfs header is now sent, with any user-supplied headers still taking precedence.

2. status !== 200 check was too strict
Replaced with !response.ok, which correctly accepts any 2xx response. Some servers return 206 Partial Content or other valid success codes for file downloads, which the old check would incorrectly treat as errors.

Also added explicit redirect: 'follow' for clarity.

Changes

  • src/lib/import-gtfs.ts

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.

1 participant