feat: switch api url and bypass cache while prerendering

This commit is contained in:
Ax333l
2022-10-27 17:36:49 +02:00
parent e7a34c2ae9
commit fe5877ade5
3 changed files with 24 additions and 3 deletions

16
src/lib/utils.ts Normal file
View File

@ -0,0 +1,16 @@
import { prerendering } from "$app/environment";
export function api_url(endpoint: string): string {
let url = `https://releases.revanced.app/${endpoint}`;
if (prerendering) {
url += '?cacheBypass=';
// Just add some random stuff to the string. Doesn't really matter what we add.
// This is here to make sure we bypass the cache while prerendering.
for (let i = 0; i < 6; i++) {
url += Math.floor(Math.random() * 10).toString();
}
}
return url;
}