Recognize self-hosted setup in firecrawl --status#111
Open
saivedant169 wants to merge 1 commit into
Open
Conversation
When credentials.json points at a custom apiUrl with no apiKey, the status command was reporting "Not authenticated" and telling users to run firecrawl login. Self-hosted Firecrawl instances do not require an API key, so the setup is valid; the CLI should report it as such. Adds a self-hosted auth source and treats it as authenticated for the status path. Updates the queue-status and credit-usage fetch helpers to omit the Authorization header when no apiKey is present, which removes the "Bearer undefined" header that was being sent against self-hosted servers. Includes regression tests for the four authSource paths (env, stored, self-hosted, none) and an explicit check that no Authorization header goes out when the apiKey is missing. Fixes firecrawl#53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
firecrawl --statuswas reportingNot authenticatedand pointing users atfirecrawl loginwhenever the stored credentials only hadapiUrlset (e.g. a self-hosted instance). Self-hosted Firecrawl does not require an API key, so this state is a valid configured setup, not a missing-credentials state.The same code path also produced
Authorization: Bearer undefinedin outbound requests whenapiKeywas missing, since the header was unconditionally formatted from a possibly-undefined value.Tracked as #53.
Repro on
mainFix
self-hostedas a newAuthSourceinsrc/commands/status.ts.getAuthSource()returnsself-hostedwhen stored credentials have a customapiUrland noapiKey.getStatus()treatsself-hostedas authenticated for reporting purposes, so the status flow keeps going and queries the queue-status / credit-usage endpoints (which the issue notes already succeed against self-hosted instances).fetchQueueStatus/fetchCreditUsagenow build headers via a smallbuildStatusHeaders()helper that omitsAuthorizationentirely when there is noapiKey. This removes theBearer undefinedheader.handleStatusCommand()printsSelf-hosted <apiUrl>in green instead of theNot authenticatedline for this state.The cloud paths (
env,stored) are unchanged.Tests
New
src/__tests__/commands/status.test.tswith four cases:apiUrlcustom + noapiKeyreportsauthSource=self-hostedandauthenticated=true.Authorizationheader is omitted entirely when self-hosted has noapiKey; the literal stringBearer undefineddoes not appear in any outgoing request.apiKey+ customapiUrlstill reportsstored(no regression on existing cloud-with-custom-URL flow).apiKey+ default cloud URL still reportsnoneandauthenticated=false.Verified locally:
npx vitest run→ 279 passed (16 files).npx tsc --noEmit→ clean.npx prettier --check→ clean.The two new self-hosted tests fail on
main(the bug), pass with the fix.