Lucas
Lucas
TtRPC
Created by h on 10/8/2023 in #❓-help
Auth through trpc procedures
something like that
10 replies
TtRPC
Created by h on 10/8/2023 in #❓-help
Auth through trpc procedures
splitLink({
condition: (op) => op.type === 'mutation', // or it can be something like op.path === 'auth.login'
true: httpBatchStreamLink(...),
false: httpBatchLink(...),
})
splitLink({
condition: (op) => op.type === 'mutation', // or it can be something like op.path === 'auth.login'
true: httpBatchStreamLink(...),
false: httpBatchLink(...),
})
10 replies
TtRPC
Created by h on 10/8/2023 in #❓-help
Auth through trpc procedures
I think the easiest approach would be to just use a splitLink that uses httpBatchStreamLink for queries and httpBatchLink for mutations
10 replies
TtRPC
Created by h on 10/8/2023 in #❓-help
Auth through trpc procedures
if the link you are using provides a streamed response, then there is your problem since httpBatchStreamLink does not support setting headers once the stream has begun (thus you cannot set cookies on a response)
10 replies
TtRPC
Created by h on 10/8/2023 in #❓-help
Auth through trpc procedures
which trpc link are you using? (httpLink, batchLink, httpBatchStreamLink, etc..)
10 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
Glad I could be of help! 👍
7 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
You can see more about how context extension works here -> https://trpc.io/docs/server/middlewares#context-extension
7 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
otherwise even though you are doing opts.ctx = ..., that does nothing
7 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
like this:
const baseProcedure = trpc.procedure.use((opts) => {
return opts.next({
ctx: {
userSession: {
id: 'dummy',
authenticated: false
}
}
})
});
const baseProcedure = trpc.procedure.use((opts) => {
return opts.next({
ctx: {
userSession: {
id: 'dummy',
authenticated: false
}
}
})
});
7 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
you should define the ctx variable by passing it as an argument to the opts.next() function you are returning
7 replies
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
try replacing your headers function in your trpc link for something like this
headers() {
const h = new Map(headers())

for (const [key] of h.entries()) {
if (key === 'content-length' || key === 'content-type') {
h.delete(key)
}
}

return Object.fromEntries(h.entries());;
},
headers() {
const h = new Map(headers())

for (const [key] of h.entries()) {
if (key === 'content-length' || key === 'content-type') {
h.delete(key)
}
}

return Object.fromEntries(h.entries());;
},
8 replies
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
you're passing the 'content-length' header from the server action request to the trpc request which causes a content-length mismatch
8 replies
TtRPC
Created by IceAge2OnDVD on 9/8/2023 in #❓-help
Next cookies() not being set on Mutation in App Dir (T3 Turbo)
This means you can't set any headers or cookies inside procedures. httpBatchLink does not have this issue due to the response not being streamed.
19 replies
TtRPC
Created by IceAge2OnDVD on 9/8/2023 in #❓-help
Next cookies() not being set on Mutation in App Dir (T3 Turbo)
If you're using unstable_httpBatchStreamLink, headers are returned at the beginning of the request (since the response is a streamed response).
19 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
did you export the methods correctly in the route handler like this?
export {
handler as GET,
handler as POST,
}
export {
handler as GET,
handler as POST,
}
53 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
At least everytime I encountered an error like that it was because I had set up something wrong in the route handler
53 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
Kinda seems like you're getting the default 404 html page from next as a response. So maybe my first guess would be that you set up the route handler incorrectly
53 replies