Skip to content

Conversation

tamanyan
Copy link

@tamanyan tamanyan commented Oct 2, 2025

🔍 Description

When configuring baseUrl for StorageBucketApi, if the API endpoint is a host-only URL (e.g., http://localhost:5000), using new URL(...).href automatically normalizes it to include a trailing slash (http://localhost:5000/).

What changed?

Remove tailing slash for baseUrl.href

Why was this change needed?

During local development of Supabase Storage, the base URL is set to http://localhost:5000. I encountered issues when calling the local API from the JS SDK.

Closes #1588

📸 Screenshots/Examples

// Host-only URL case
const baseUrl = new URL("http://localhost:5000").href;
console.log(baseUrl); 
// => "http://localhost:5000/"   <-- trailing slash added

// Path-included URL works fine
const baseUrlWithPath = new URL("http://localhost:5000/storage/v1").href;
console.log(baseUrlWithPath); 
// => "http://localhost:5000/storage/v1"

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

📝 Additional notes

None

@tamanyan tamanyan requested review from a team as code owners October 2, 2025 16:11
@mandarini mandarini self-assigned this Oct 3, 2025
@coveralls
Copy link

Coverage Status

coverage: 95.455% (+12.0%) from 83.445%
when pulling 4565db2 on tamanyan:fix/url-trailing-slash
into 9792a92 on supabase:master.

@mandarini mandarini added the storage-js Related to the storage-js library. label Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
storage-js Related to the storage-js library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StorageBucketApi baseUrl with host-only URL (http://localhost:5000) gets normalized with a trailing slash
3 participants