feat: Implement initial Vue 3 application structure with SSR, routing, authentication, and core dashboard components.
This commit is contained in:
@@ -2,18 +2,19 @@ import { tryGetContext } from "hono/context-storage";
|
||||
|
||||
export const customFetch = async (url: string, options: RequestInit) => {
|
||||
options.credentials = "include";
|
||||
if (!options.headers) {
|
||||
options.headers = {};
|
||||
}
|
||||
if (import.meta.env.SSR) {
|
||||
const c = tryGetContext<any>();
|
||||
if (!c) {
|
||||
throw new Error("Hono context not found in SSR");
|
||||
}
|
||||
// Object.entries(c.req.header()).forEach(([k, v]) => {
|
||||
// Object.assign(options.headers!, { [k]: v });
|
||||
// });
|
||||
return await c.get("fetch")(url, options);
|
||||
Object.assign(options, {
|
||||
headers: c.req.header()
|
||||
});
|
||||
const res = await fetch(url, options);
|
||||
res.headers.forEach((value, key) => {
|
||||
c.header(key, value);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
return fetch(url, options);
|
||||
}
|
||||
Reference in New Issue
Block a user