update ui

This commit is contained in:
2026-01-25 17:30:17 +07:00
parent ac74faadbe
commit 770c09b9b2
8 changed files with 463 additions and 30 deletions

View File

@@ -1,25 +1,40 @@
import { tryGetContext } from "hono/context-storage";
export const customFetch = async (url: string, options: RequestInit) => {
export const customFetch = (url: string, options: RequestInit) => {
options.credentials = "include";
if (import.meta.env.SSR) {
const c = tryGetContext<any>();
if (!c) {
throw new Error("Hono context not found in SSR");
}
Object.assign(options, {
headers: c.req.header()
});
console.log("url", url)
const res = await fetch(["https://api.pipic.fun", url.replace(/r\//, '')].join('/'), options);
if (url.includes("r/plans")) {
console.log("res", await res.json())
// Merge headers properly - keep original options.headers and add request headers
const reqHeaders = new Headers(c.req.header());
// Remove headers that shouldn't be forwarded
reqHeaders.delete("host");
reqHeaders.delete("connection");
}
res.headers.forEach((value, key) => {
c.header(key, value);
const mergedHeaders: Record<string, string> = {};
reqHeaders.forEach((value, key) => {
mergedHeaders[key] = value;
});
options.headers = {
...mergedHeaders,
...(options.headers as Record<string, string>)
};
const apiUrl = ["https://api.pipic.fun", url.replace(/^r/, '')].join('');
// const res = await fetch(apiUrl, options);
// Forward response headers to client (especially Set-Cookie)
// res.headers.forEach((value, key) => {
// c.header(key, value);
// });
return fetch(apiUrl, options).then(res => {
// Forward response headers to client (especially Set-Cookie)
res.headers.forEach((value, key) => {
c.header(key, value);
});
return res;
});
return res;
}
return fetch(url, options);
}