-
IssueAfter migrating my Next.js app to use the new
DetailsAfter debugging for a while, I found the issue in the generated This is what it is usually generated as:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hey @buffalom, would you be able to print out the offending value ( |
Beta Was this translation helpful? Give feedback.
-
I wrote this utility function for this: import { type DefaultError, type QueryKey, type UseQueryOptions } from '@tanstack/react-query';
const BASE_URL_KEY = 'baseUrl' as const;
/**
* Removes `baseUrl` from the `queryKey` of the provided query options.
* This is useful for avoiding hydration mismatches since the Hey API clients in
* the BFF and the browser have different base URLs.
*
* @see https://github.com/orgs/hey-api/discussions/1261
* @license MIT
*/
export function queryOptionsWithoutBaseUrl<
TQueryFnData = unknown,
TError = DefaultError,
TData = TQueryFnData,
TQueryKey extends QueryKey = QueryKey,
>(
options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
): UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> {
return {
...options,
// @ts-expect-error removing `baseUrl` from the queryKey changes the type,
// but not in a way that should break any contracts
queryKey: options.queryKey.map((key) => {
if (typeof key === 'object' && key !== null && BASE_URL_KEY in key) {
const { [BASE_URL_KEY]: _, ...rest } = key;
return rest;
}
return key;
}),
};
} I tried mapping the |
Beta Was this translation helpful? Give feedback.
Hey @buffalom, would you be able to print out the offending value (
baseUrl
)? I suspect in CI it will be somehowundefined
. If you could confirm that, it might point us in the right direction