aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Utility/proxy.ts
blob: 0af8c66af13f4e321b3a74b9aefd8571ab37d80d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { env } from '$env/dynamic/public';

export const proxy = (url: string, disable = false) => {
	const randomKey = Math.floor(Math.random() * 90) + 10;

	return env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') && !disable
		? url
		: `https://proxy.due.moe/?d2=${btoa(
				url
					.split('')
					.map((char) => char.charCodeAt(0) + randomKey)
					.join(':')
		  )}${randomKey}`;
};

export default proxy;