-
Notifications
You must be signed in to change notification settings - Fork 480
Labels
bugSomething isn't workingSomething isn't workingstorage-jsRelated to the storage-js library.Related to the storage-js library.
Description
Describe the bug
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/).
Example:
// 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"
This becomes an issue because StorageBucketApi may construct requests incorrectly when the baseUrl is http://localhost:5000/ instead of the expected http://localhost:5000.
Library affected
storage-js
Reproduction
No response
Steps to reproduce
const storageClient = new StorageClient('http://localhost:5000', {
apikey: SERVICE_KEY,
Authorization: `Bearer ${SERVICE_KEY}`,
})
await this.client.listBuckets()
System Info
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.10 GB / 64.00 GB
Shell: 3.7.1 - /opt/homebrew/bin/fish
Binaries:
Node: 22.20.0 - ~/.anyenv/envs/nodenv/versions/22.20.0/bin/node
npm: 10.9.3 - ~/.anyenv/envs/nodenv/versions/22.20.0/bin/npm
Watchman: 2023.04.17.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 140.0.7339.214
Chrome Canary: 143.0.7446.1
Edge: 140.0.3485.94
Safari: 17.6
npmPackages:
@supabase/storage-js: ^2.12.2 => 2.12.2
Used Package Manager
npm
Logs
Storage Service
2025-10-02T15:24:01.684Z] WARN (47233 on xxxxx): storage-single-tenant | GET | 404 | 127.0.0.1 | req-16 | / | node
region: "local"
reqId: "req-16"
tenantId: "storage-single-tenant"
project: "storage-single-tenant"
appVersion: "0.0.0"
type: "request"
req: {
"region": "local",
"traceId": "req-16",
"method": "GET",
"url": "/",
"headers": {
"host": "localhost:5000",
"x_client_info": "storage-js/2.12.2",
"accept": "*/*",
"user_agent": "node"
},
"hostname": "localhost:5000",
"remoteAddress": "127.0.0.1",
"remotePort": 63971
}
res: {
"statusCode": 404,
"headers": {
"content_type": "application/json; charset=utf-8",
"content_length": "79"
}
}
responseTime: 0.2705416679382324
resources: [
"/bucket"
]
}
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Supabase JS Library issue and not an issue with the Supabase platform. If it's a Supabase platform related bug, it should likely be reported to supabase/supabase instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstorage-jsRelated to the storage-js library.Related to the storage-js library.