Files
roblox/lib/utils.ts
2025-07-23 23:34:43 +03:00

33 lines
737 B
TypeScript

import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export async function proxyFetch(
input: RequestInfo | URL,
init?: RequestInit
): Promise<Response> {
const url =
typeof input === "string"
? input
: input instanceof Request
? input.url
: "";
const proxyUrl = `/api/proxy?url=${encodeURIComponent(url)}`;
// fix headers
const headers = new Headers(init?.headers || {});
headers.delete("accept-encoding"); // prevent stupid encoding bug
const fetchInit: RequestInit = {
...init,
method: init?.method || "GET",
headers,
body: init?.body,
};
return window.fetch(proxyUrl, fetchInit);
}