-
|
Beta Was this translation helpful? Give feedback.
Answered by
qhj
Aug 9, 2024
Replies: 1 comment
-
Solved. import { createResource } from "solid-js";
import { getRequestEvent } from "solid-js/web";
export default function Home() {
const [test] = createResource(async () => {
return (
await fetch("http://localhost:3000/api/test", {
headers: getRequestEvent()?.request.headers,
})
).text();
});
return (
<>
<div>{test()}</div>
</>
);
} My acturally question is how to getting cookies in trpc querying issued in ssr phase: import { createTRPCClient, httpBatchLink } from "@trpc/client";
import type { AppRouter } from "./router";
import { getRequestEvent } from "solid-js/web";
export const trpc = createTRPCClient<AppRouter>({
links: [
httpBatchLink({
url: "http://localhost:3000/api/trpc",
headers() {
const cookie = getRequestEvent()?.request.headers.get("cookie");
return cookie != null ? { cookie } : {};
},
}),
],
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
qhj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved.
My acturally question is how to getting cookies in trpc querying issued in ssr phase: