Revert "fix: test fix broken dashboard #1"
This reverts commit 24ee6b0b6c.
# Conflicts:
# apps/start/src/integrations/tanstack-query/root-provider.tsx
This commit is contained in:
@@ -12,11 +12,6 @@ import { useMemo } from 'react';
|
|||||||
export const getIsomorphicHeaders = createIsomorphicFn()
|
export const getIsomorphicHeaders = createIsomorphicFn()
|
||||||
.server(() => {
|
.server(() => {
|
||||||
const headers = getRequestHeaders();
|
const headers = getRequestHeaders();
|
||||||
// Filter out headers that shouldn't be forwarded to the API
|
|
||||||
// - host: Would send wrong host (dashboard host instead of API host)
|
|
||||||
// - connection: Hop-by-hop header
|
|
||||||
// - upgrade-insecure-requests: Browser-specific
|
|
||||||
// - sec-*: Browser security headers not relevant for server-to-server
|
|
||||||
const forwardHeaders: Record<string, string> = {};
|
const forwardHeaders: Record<string, string> = {};
|
||||||
const skipHeaders = new Set([
|
const skipHeaders = new Set([
|
||||||
'host',
|
'host',
|
||||||
@@ -52,40 +47,35 @@ export function createTRPCClientWithHeaders(apiUrl: string) {
|
|||||||
url: `${apiUrl}/trpc`,
|
url: `${apiUrl}/trpc`,
|
||||||
headers: () => getIsomorphicHeaders(),
|
headers: () => getIsomorphicHeaders(),
|
||||||
fetch: async (url, options) => {
|
fetch: async (url, options) => {
|
||||||
const isServer = typeof window === 'undefined';
|
|
||||||
|
|
||||||
const fetchOptions: RequestInit = {
|
|
||||||
method: options?.method,
|
|
||||||
headers: options?.headers,
|
|
||||||
body: options?.body,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, fetchOptions);
|
console.log('fetching', url, options);
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...options,
|
||||||
|
mode: 'cors',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
// Log HTTP errors on server
|
// Log HTTP errors on server
|
||||||
if (!response.ok && isServer) {
|
if (!response.ok && typeof window === 'undefined') {
|
||||||
const text = await response.clone().text();
|
const text = await response.clone().text();
|
||||||
console.error('[tRPC SSR Error]', {
|
console.error('[tRPC SSR Error]', {
|
||||||
url: url.toString(),
|
url: url.toString(),
|
||||||
status: response.status,
|
status: response.status,
|
||||||
statusText: response.statusText,
|
statusText: response.statusText,
|
||||||
body: text,
|
body: text,
|
||||||
|
options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Log fetch errors on server
|
// Log fetch errors on server
|
||||||
if (isServer) {
|
if (typeof window === 'undefined') {
|
||||||
console.error('[tRPC SSR Error]', {
|
console.error('[tRPC SSR Error]', {
|
||||||
url: url.toString(),
|
url: url.toString(),
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: error instanceof Error ? error.message : String(error),
|
||||||
stack: error instanceof Error ? error.stack : undefined,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
cause:
|
options,
|
||||||
error instanceof Error && error.cause
|
|
||||||
? String(error.cause)
|
|
||||||
: undefined,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user