fix: test fix broken dashboard #2
This commit is contained in:
@@ -54,26 +54,12 @@ export function createTRPCClientWithHeaders(apiUrl: string) {
|
|||||||
fetch: async (url, options) => {
|
fetch: async (url, options) => {
|
||||||
const isServer = typeof window === 'undefined';
|
const isServer = typeof window === 'undefined';
|
||||||
|
|
||||||
// Build fetch options differently for server vs client
|
|
||||||
// Server (Node.js): Don't use browser-specific options like mode/credentials
|
|
||||||
// Also filter out signal: null which can cause issues in undici
|
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
method: options?.method,
|
method: options?.method,
|
||||||
headers: options?.headers,
|
headers: options?.headers,
|
||||||
body: options?.body,
|
body: options?.body,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only add browser-specific options on client
|
|
||||||
if (!isServer) {
|
|
||||||
fetchOptions.mode = 'cors';
|
|
||||||
fetchOptions.credentials = 'include';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only pass signal if it's a valid AbortSignal (not null)
|
|
||||||
if (options?.signal) {
|
|
||||||
fetchOptions.signal = options.signal;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, fetchOptions);
|
const response = await fetch(url, fetchOptions);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user