Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/brown-pens-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/storage": patch
"@firebase/util": patch
---

Fixed issue where Storage on Firebase Studio throws CORS errors.
2 changes: 1 addition & 1 deletion common/api-review/util.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export function isBrowserExtension(): boolean;
export function isCloudflareWorker(): boolean;

// @public
export function isCloudWorkstation(host: string): boolean;
export function isCloudWorkstation(url: string): boolean;

// Warning: (ae-missing-release-tag) "isElectron" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/test/browser/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Connections', () => {
const fakeXHR = useFakeXMLHttpRequest();
const connection = new XhrBytesConnection();
const sendPromise = connection.send(
'https://abc.cloudworkstations.dev',
'https://abc.cloudworkstations.dev/test',
'GET',
true
);
Expand Down
10 changes: 9 additions & 1 deletion packages/util/src/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
* Checks whether host is a cloud workstation or not.
* @public
*/
export function isCloudWorkstation(host: string): boolean {
export function isCloudWorkstation(url: string): boolean {
// `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
// In HTTP request builders, it's called with the protocol.
// If called with protocol prefix, it's a valid URL, so we extract the hostname
// If called without, we assume the string is the hostname.
const host =
url.startsWith('http://') || url.startsWith('https://')
? new URL(url).hostname
: url;
return host.endsWith('.cloudworkstations.dev');
}

Expand Down
Loading