Skip to content

Storage HTTPx client doesn't have a base_url #1294

@weshoke

Description

@weshoke

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • [ x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using the 2.22.3 Python client, I'm finding the create_signed_upload_url doesn't have a base_url.
I traced it to when the storage object is created from the client, a base_url isn't being passed in to where the HTTP client is created. If options.http_client is None, which it is in my case,

self.session = http_client or AsyncClient(
            headers=headers,
            timeout=self.timeout,
            proxy=proxy,
            verify=self.verify,
            follow_redirects=True,
            http2=True,
        )

This code will create an async client and it's not passing in base_url, so it's set as the empty string. This leaves the pre-signed URLs having no protocol/domain, etc.

To Reproduce

I'm running this in a local dev environment

This is my hack to get it to work:

async def generate_presigned_url(
    storage_client: AsyncClient,
    bucket: str,
    storage_path: str,
) -> str:
    """Generate presigned URL for upload to Supabase storage."""
    bucket_client = storage_client.storage.from_(bucket)
    # For some reason, the base URL is not set correctly
    # NOTE: Supabase bug?
    if bucket_client._client.base_url == "":
        bucket_client._client.base_url = f"{settings.supabase_url}/storage/v1/"
    result = await storage_client.storage.from_(bucket).create_signed_upload_url(storage_path)

    return result["signed_url"]

Expected behavior

The returned URL should have a protocol and domain.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

OSX, Python client, 2.22.3

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions