Skip to content

fix(python-sdk): preserve api_url path prefix in _build_url (fixes #4339) - #4408

Open
AbhiPra24 wants to merge 2 commits into
firecrawl:mainfrom
AbhiPra24:fix/v2-http-client-path-prefix
Open

fix(python-sdk): preserve api_url path prefix in _build_url (fixes #4339)#4408
AbhiPra24 wants to merge 2 commits into
firecrawl:mainfrom
AbhiPra24:fix/v2-http-client-path-prefix

Conversation

@AbhiPra24

Copy link
Copy Markdown

Fixes #4339

Description

When self-hosted Firecrawl is deployed behind a reverse proxy with a path prefix (e.g. api_url = "http://firecrawl.example.com/firecrawl"), _build_url previously used urljoin(base_str, endpoint) with endpoints like "/v2/search". In Python's urllib.parse.urljoin, leading slashes in relative endpoint paths replace the base URL's entire path component, dropping /firecrawl and sending requests to http://firecrawl.example.com/v2/search.

This PR fixes _build_url in HttpClient to:

  • Preserve the base URL's path prefix when resolving relative endpoints.
  • Support both leading-slash and non-leading-slash endpoints uniformly.
  • Preserve query parameters and security checks (host normalization).
  • Adds dedicated unit tests in test_http_client.py covering standard URLs, trailing slash variants, path prefixes, nested prefixes, query params, and domain normalization.

Verification

  • 478/478 unit tests pass.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/python-sdk/firecrawl/v2/utils/http_client.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Re-trigger cubic

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.

v2 client _build_url drops path prefix from api_url (urljoin with leading-slash endpoint)

1 participant