test setup lackin

This commit is contained in:
2025-09-03 22:04:56 +02:00
parent 869cc07fdd
commit 276c3dd75f
35 changed files with 629 additions and 285 deletions

View File

@@ -4,21 +4,7 @@ import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experime
import { httpBatchLink } from "@trpc/client";
import React, { useState } from "react"
import { trpc } from "./Client";
function getBaseUrl() {
if (typeof window !== 'undefined')
// browser should use relative path
return '';
if (process.env.VERCEL_URL)
// reference for vercel.com
return `https://${process.env.VERCEL_URL}`;
if (process.env.RENDER_INTERNAL_HOSTNAME)
// reference for render.com
return `http://${process.env.RENDER_INTERNAL_HOSTNAME}:${process.env.PORT}`;
// assume localhost
return `http://localhost:${process.env.PORT ?? 3000}`;
}
import getBaseUrl from "~/app/_trpc/GetBaseUrl";
let clientQueryClient: QueryClient | undefined = undefined;
const makeQueryClient = () => new QueryClient({
defaultOptions: {
@@ -38,12 +24,15 @@ function getQueryClient() {
}
}
export default function TrpcProvider({ children }: { children: React.ReactNode }) {
console.log("provider calls get base url")
const baseUrl = getBaseUrl()
console.log("provider got baseurl:", baseUrl)
const queryClient = getQueryClient();
const [trpcClient] = useState(() => {
return trpc.createClient({
links: [
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
url: `${baseUrl}/api/trpc`,
}),
],
})