Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit d847f70

Browse files
authored
fix: LSDV-4593: CORS error requesting audio (#1234)
* fix: LSDV-4593: CORS error requesting audio * use a less likely query param, ensure all relative urls are handled so 404 errors are thrown correctly
1 parent 91b4ca3 commit d847f70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/AudioUltra/Media/MediaLoader.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,15 @@ export class MediaLoader extends Destructable {
185185
}
186186
});
187187

188-
xhr.open('GET', url, true);
188+
// Handle relative urls, by converting them to absolute so any query params can be preserved
189+
const newUrl = new URL(url, /^https?/.exec(url) ? undefined : window.location.href);
190+
191+
// Arbitrary setting of query param to stop caching from reusing any media requests which may have less headers
192+
// cached than this request. This is to prevent a CORS error when the headers are different between partial
193+
// content and full content requests.
194+
newUrl.searchParams.set('lsref', '1');
195+
196+
xhr.open('GET', newUrl.toString(), true);
189197
xhr.send();
190198
});
191199
}

0 commit comments

Comments
 (0)