fix(storage): make dedicated storage host opt-in via useNewHostname flag#1329
Merged
grdsdev merged 1 commit intoMar 25, 2026
Conversation
_transformStorageUrl unconditionally rewrote all storage URLs to use the dedicated storage host (*.storage.supabase.co), which is not available on all projects. This silently broke every storage operation with StorageException: Invalid Storage request. Option B: change the default to opt-in (useNewHostname defaults to false). Projects that have the dedicated storage host enabled can opt in via StorageClientOptions(useNewHostname: true) in Supabase.initialize(). The URL transformation logic and its tests are preserved; they now run only when useNewHostname: true is passed. Fixes: #1328 Linear: SDK-789 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression in storage_client 2.5.0 where storage base URLs were always rewritten to the dedicated storage hostname (*.storage.supabase.co), breaking projects that don’t have that host enabled. It makes the rewrite behavior opt-in via a useNewHostname flag, defaulting to false, and wires the option through the supabase package.
Changes:
- Add
useNewHostname(defaultfalse) toSupabaseStorageClientto gate_transformStorageUrl()behind an opt-in flag. - Expose
useNewHostnameviaStorageClientOptionsinsupabaseand pass it through when initializing the storage client. - Reorganize and expand URL-construction tests to cover both default (no transform) and opt-in (transform) behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/supabase/lib/src/supabase_client_options.dart | Adds StorageClientOptions.useNewHostname with documentation and default false. |
| packages/supabase/lib/src/supabase_client.dart | Threads useNewHostname from StorageClientOptions into SupabaseStorageClient initialization. |
| packages/storage_client/lib/src/storage_client.dart | Makes legacy→dedicated host rewrite conditional on useNewHostname. |
| packages/storage_client/test/basic_test.dart | Splits URL construction tests into default vs opt-in groups and adds coverage for the default path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
o-santi
approved these changes
Mar 25, 2026
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.
Summary
storage_client2.5.0 introduced_transformStorageUrl()which unconditionally rewrites all storage URLs to use the dedicated storage host (*.storage.supabase.co). This host is not available on all projects, silently breaking every storage operation withStorageException: Invalid Storage request.This PR implements Option B: make the URL transformation opt-in (
useNewHostnamedefaults tofalse). Projects with the dedicated storage host enabled can opt in viaStorageClientOptions(useNewHostname: true)inSupabase.initialize().Changes
storage_client: AddeduseNewHostnameparameter toSupabaseStorageClient(defaults tofalse)supabase: AddeduseNewHostnamefield toStorageClientOptions, threaded through toSupabaseStorageClientdefault behavior (useNewHostname: false)andopt-in behavior (useNewHostname: true)groups; added 6 new tests covering the default no-transform pathRoot Cause
packages/storage_client/lib/src/storage_client.dart:45_transformStorageUrl(url)was called unconditionally at construction timeuseNewHostname ? _transformStorageUrl(url) : urlTesting
Reproduction Test
All 35 tests in
storage_clientpass, including 12 URL construction tests that explicitly verify both the default (no transform) and opt-in (transform) paths.Test Coverage
Manual Testing
*.storage.supabase.coenabled (default should work)useNewHostname: trueRisk Assessment
StorageClientOptions(useNewHostname: true). This is intentional (Option B).storageOptions: StorageClientOptions(useNewHostname: true)toSupabase.initialize()if your project has the dedicated storage host enabled.Acceptance Criteria
useNewHostname: trueflag available fromStorageClientOptionsthrough toSupabaseStorageClientuseNewHostname: falsedefault pathStorageFileApisurfaceLinear Issue
Closes: SDK-789
GitHub: #1328
🤖 Generated with Claude Code
/take