-
-
Notifications
You must be signed in to change notification settings - Fork 556
Closed
Description
Provide environment information
N/A
Describe the bug
A common use case, is to call an api route, after a trpc complete, for example to send an email. API route is usually protected with
// api/emails/notify.ts
const session = await auth()
if(!session){
return new Response("Unauthorized", {status:401})
}Because request headers are not available in the trpc procedure, i'm unable to forward them to the fetch call. Is there a better way around it.
USE case
create: protectedProcedure
.input(CreatePostSchema)
.mutation(({ ctx, input }) => {
const v = ctx.db.insert(Post).values(input);
// WANT TO DO THIS.
fetch(`/api/emails/notify`, {
// i would like to forward the user session
});
return v;
}),Another solution will be to send this into a redis queue, and process these ops later. But that's not the point. I would like to make api calls from trpc procedure. This is just a simplified use case.
Link to reproduction
https://github.com/t3-oss/create-t3-turbo
To reproduce
N/A
Additional information
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels