[Glitch] Enables cross-origin Web Workers

Port 7f9ad7eabf to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-07-24 09:14:27 +02:00
committed by Claire
parent cee41da8d8
commit ec412e1748
3 changed files with 36 additions and 6 deletions

View File

@@ -36,15 +36,16 @@ async function fetchAndCheckEtag<ResultType extends object[]>(
): Promise<ResultType | null> {
const locale = toSupportedLocaleOrCustom(localeOrCustom);
let uri: string;
// Use location.origin as this script may be loaded from a CDN domain.
const url = new URL(location.origin);
if (locale === 'custom') {
uri = '/api/v1/custom_emojis';
url.pathname = '/api/v1/custom_emojis';
} else {
uri = `/packs${isDevelopment() ? '-dev' : ''}/emoji/${locale}.json`;
url.pathname = `/packs${isDevelopment() ? '-dev' : ''}/emoji/${locale}.json`;
}
const oldEtag = await loadLatestEtag(locale);
const response = await fetch(uri, {
const response = await fetch(url, {
headers: {
'Content-Type': 'application/json',
'If-None-Match': oldEtag ?? '', // Send the old ETag to check for modifications