404 TRPCError: no query procedure on path

Hi, this is my entire standalone tRPC server:
import { initTRPC } from "@trpc/server";
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import cors from "cors";

const t = initTRPC.create();
const appRouter = t.router({
foo: t.procedure.query(() => "hi"),
});

const server = createHTTPServer({
middleware: cors(),
router: appRouter,
});

export type AppRouter = typeof appRouter;

server.listen(3000);
import { initTRPC } from "@trpc/server";
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import cors from "cors";

const t = initTRPC.create();
const appRouter = t.router({
foo: t.procedure.query(() => "hi"),
});

const server = createHTTPServer({
middleware: cors(),
router: appRouter,
});

export type AppRouter = typeof appRouter;

server.listen(3000);
and here is my tRPC client:
const trpcClient = trpc.createClient({
links: [
httpBatchLink({
url: "http://localhost:3000/trpc"
}),
],
});
const trpcClient = trpc.createClient({
links: [
httpBatchLink({
url: "http://localhost:3000/trpc"
}),
],
});
but when i use it with trpc.foo.useQuery(), this the response:
{
"error": {
"message": "No \"query\"-procedure on path \"trpc/foo\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"stack": "TRPCError: No \"query\"-procedure on path \"trpc/foo\"\n at new TRPCError (/somepath/node_modules/@trpc/server/dist/TRPCError-6a1653a4.mjs:52:12)\n at callProcedure
[...]
}
}
}
{
"error": {
"message": "No \"query\"-procedure on path \"trpc/foo\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"stack": "TRPCError: No \"query\"-procedure on path \"trpc/foo\"\n at new TRPCError (/somepath/node_modules/@trpc/server/dist/TRPCError-6a1653a4.mjs:52:12)\n at callProcedure
[...]
}
}
}
What am i doing wrong? I already tried removing /trpc from the url that the client uses which also resulted in 404.
T
thomasplayschess218d ago
Maybe the URL is just wrong? Try to change this url: "http://localhost:3000/trpc" to this: url: "http://localhost:3000" At least it looks to me like you are not setting it up on any path, so the default should just be http://localhost:3000
F
funki218d ago
i did try that, i've already mentioned it ^^ maybe i didn't try without slash
T
thomasplayschess217d ago
Is the server behind a reverse proxy? What do you get when you call http://localhost:3000/foo?
F
funki217d ago
that can't be the issue, the response is clear no reverse proxy the request comes through but i'll check /foo when i'm back home not sure what to expect tho bc trpc isn't rest
T
thomasplayschess217d ago
It should give you something like "400 Bad Request" and not a 404 if the path is correct.
F
funki216d ago
@thomasplayschess yeah the issue was simply that i tried localhost:4321/ instead of localhost:4321 as the URL for the link. it works now :) thanks
T
thomasplayschess216d ago
Awesome, glad I could help! 🙂
More Posts
Call multiple TRPC endpoints from onSuccess()?I would like to create an API chain for analysing a geographic area where one successful API call caHow to set sizeLimit > 1MB (to solve 413 error)?Hi all, I am trying out the T3 stack where I want to send area polygons given by the user to my NexHow to manage server to server communicationWould managing headers this way work in nextjs as server to server communication? or does next managReplacing the dot notation in URLs with forward slash `/` ?is there a way to replace the dot separation with a forward slash instead ? so instead of `/api/tWhich one method should I use for creating trpc for server componetns in Nextjs 13 App dirHi which one I should use experimental_createTRPCNextAppDirServer or createTRPCProxyClient when it cCan someone explain to me the use of tRPC in server components?I can really see the need for tRPC in client components but can someone explain to me how you would Error-Boundary and TRPCIs there a nice way to catch errors from TRPC at a global level and bubble them into a simple alert Type errors in lambda integrationI really don't know where to start with this error.... I'm going to be integrating tRPC into a lambHybrid application with offline and online mode setup with tRPCHi, I was wondering if I could setup tRPC in way that one http link is using local API (for offline query with no input reports errori have a simple router with a list procedure that takes no input and just does a .query() it used tNext cookies() not being set on Mutation in App Dir (T3 Turbo)Trying to set cookies inside TRPC using Nextjs App Router, using the T3 Turbo setup. Setting cookietRPC error in app Router (undefined headers)I use the tRPC file structure from Jack Herringtons video I added clerk auth for protected routes anBad request in prod but works fine in devin prod I am getting `BAD REQUEST`hey is there any way to integrate or implement machine learning / ai in trpcSpecifically for next.js or tensorflow?How to serve files with trpc?Is is possible to serve files with trpc? E.g., by creating a middleware and returning directly from tRPC in Next without api rotesHello! I have NextJS app that gets data in gSP using some third-party client. This data comes untypegetting the progress of a trpc queryHello, I want to be able to stream the progress of a trpc client query call, so I can link it to a pwrapper on useMutation (and another for useQuery) for creating multiple hookshi i want to create a wrapper for my router, basically I would like to achive somethink like that useQuery returning old data with new paramsI have a react component that takes in a date range and calculates a users net worth (sums up all asCalling a tRPC service from another tRPC serviceI have 2 services (App1 and Service2) App1 is client facing and uses trpc well But occasionally App1