Add webapp release
Some checks failed
Queue Release Build / prepare (push) Successful in 50s
Queue Release Build / build-windows (push) Has been cancelled
Queue Release Build / finalize (push) Has been cancelled
Queue Release Build / build-linux (push) Has been cancelled
Deploy Web Apps / deploy (push) Has been cancelled

This commit is contained in:
2026-03-12 13:36:39 +01:00
parent 45e0b09af8
commit 3c04b5db26
5 changed files with 230 additions and 9 deletions

23
website/public/web.config Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".wasm" />
<remove fileExtension=".webmanifest" />
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

View File

@@ -55,6 +55,8 @@ const ARCHIVE_SUFFIXES = [
'.7z',
'.rar'
];
const DIRECT_RELEASES_API_URL = 'https://git.azaaxin.com/api/v1/repos/myxelium/Toju/releases';
const PROXY_RELEASES_API_URL = '/api/releases';
function matchesAssetPattern(name: string, suffixes: string[], hints: string[] = []): boolean {
if (suffixes.some((suffix) => name.endsWith(suffix))) {
@@ -205,15 +207,7 @@ export class ReleaseService {
private async fetchReleasesInternal(): Promise<Release[]> {
try {
const response = await fetch('/api/releases', {
headers: { Accept: 'application/json' }
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
const data = await this.fetchReleasesFromAvailableEndpoints();
this.cachedReleases = Array.isArray(data) ? data : [data];
@@ -226,4 +220,41 @@ export class ReleaseService {
this.fetchPromise = null;
}
}
private async fetchReleasesFromAvailableEndpoints(): Promise<Release[] | Release> {
let lastError: unknown = null;
for (const endpoint of this.getReleaseEndpoints()) {
try {
const response = await fetch(endpoint, {
headers: { Accept: 'application/json' }
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return await response.json();
} catch (error) {
lastError = error;
}
}
throw lastError instanceof Error
? lastError
: new Error('Failed to fetch releases from all configured endpoints.');
}
private getReleaseEndpoints(): string[] {
if (!isPlatformBrowser(this.platformId)) {
return [PROXY_RELEASES_API_URL, DIRECT_RELEASES_API_URL];
}
const hostname = window.location.hostname;
const isLocalHost = hostname === 'localhost' || hostname === '127.0.0.1';
return isLocalHost
? [PROXY_RELEASES_API_URL, DIRECT_RELEASES_API_URL]
: [DIRECT_RELEASES_API_URL, PROXY_RELEASES_API_URL];
}
}