Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tRPC plugin default endpoint does not work or missing opts in docs #321

Open
remuspoienar opened this issue Apr 25, 2024 · 0 comments
Open

Comments

@remuspoienar
Copy link

remuspoienar commented Apr 25, 2024

What is the type of issue?

Documentation is missing, Example code is not working

What is the issue?

I am using elysia + tRPC plugin and started a small setup based on the docs here
The issue is that is i configure a client on localhost:3000 i get a 404 issue.

Screenshot 2024-04-25 at 15 16 57

This can be fixed by adding the and endpoint(without the trailing slash, otherwise its 404 again), but it should be mentioned that it is needed. I don't assume this is a bug on the trpc plugin, though a default "/" could be assumed and used.

Screenshot 2024-04-25 at 15 17 17

Edit: forgot to add server code

import { z } from "zod";
import { initTRPC } from "@trpc/server";

const t = initTRPC.create();
const publicProcedure = t.procedure;

const appRouter = t.router({
  greet: publicProcedure
    .input(z.object({ name: z.string() }))
    .query(async ({ input }) => ({ greet: input.name })),

  storeGreet: publicProcedure
    .input(z.object({ name: z.string() }))
    .mutation(async (opts) => {
      console.log({ opts });
      const { input } = opts;
      return { greet: input.name };
    }),
});

export type AppRouter = typeof appRouter;
export default appRouter;

Where did you find it?

(https://elysiajs.com/plugins/trpc.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant