rockchalkwushock
rockchalkwushock
Explore posts from servers
TtRPC
Created by rockchalkwushock on 4/21/2023 in #❓-help
How does routing work in tRPC especially when using merged routers?
I am having trouble understanding how tRPC lays out routes. Let's say I have the below
export const apiRouter = router({
version: publicProcedure.query(() => {
return { version: '0.42.0' }
}),
hello: publicProcedure
.input(z.object({ username: z.string().nullish() }).nullish())
.query(({ input, ctx }) => {
return {
text: `hello ${input?.username ?? ctx.user?.name ?? 'world'}`,
}
}),
})

export const appRouter = router({
api: apiRouter,
// ...other routers
})

// server.ts
server.register(fastifyTRPCPlugin, {
prefix: '/trpc',
trpcOptions: { router: appRouter, createContext },
})
export const apiRouter = router({
version: publicProcedure.query(() => {
return { version: '0.42.0' }
}),
hello: publicProcedure
.input(z.object({ username: z.string().nullish() }).nullish())
.query(({ input, ctx }) => {
return {
text: `hello ${input?.username ?? ctx.user?.name ?? 'world'}`,
}
}),
})

export const appRouter = router({
api: apiRouter,
// ...other routers
})

// server.ts
server.register(fastifyTRPCPlugin, {
prefix: '/trpc',
trpcOptions: { router: appRouter, createContext },
})
My assumption is that from the above example I have:
GET /trpc/api/version
GET /trpc/api/hello?username=Bob
GET /trpc/api/version
GET /trpc/api/hello?username=Bob
However when using Insomnia to query the endpoints as I familiarize myself with tRPC more I get 404s. Could someone explain this to me better? I am running:
@trpc/server 10.21.0
pnpm 8.2.0
node 18.15.0
@trpc/server 10.21.0
pnpm 8.2.0
node 18.15.0
4 replies
CDCloudflare Developers
Created by rockchalkwushock on 2/20/2023 in #pages-help
Where to find my site's IP Address for setting up sub-domain
When configuring a sub-domain where do I get the IP Address for my website? I am using Cloudflare Pages so the top level domain is aliased to the *.pages.dev instance. I just don't know where to find this so that I can properly route the traffic. Been scanning through the docs but not finding anything here either. Anyone know where that can be found?
33 replies
CDCloudflare Developers
Created by rockchalkwushock on 2/16/2023 in #pages-help
Subdomains with Cloudflare Pages
I am having some trouble understanding what needs to happen with the configuration to achieve what I want: I want to set up blog.my-site.com and have all the routes associated to /blog in may application go through that subdomain. So I set the CNAME blog and from the documentation the {SITE_NAME}.pages.dev as the target. I can't make that {SITE_NAME}.pages.dev/blog or the form yells at me so I assume that I would need to setup a Page Rule for forwarding? This is where I'm super confused on how the DNS maps to my applications routes and visa versa.
4 replies