hello new update
This commit is contained in:
32
lib/utils.ts
32
lib/utils.ts
@@ -1,6 +1,32 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user