If the returned value of the fetched endpoint is blank that gets converted to undefined, which confuses the request sharing between the client and server causing the session to be requested on both sides. Transform value to null if it's blank so that the session fetch is de-duplicated.
6 lines
140 B
TypeScript
6 lines
140 B
TypeScript
export const useAccountSession = () => useFetch(
|
|
"/api/auth/session",
|
|
{
|
|
transform: (input) => input === undefined ? null : input,
|
|
}
|
|
);
|