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

req.headers.get is not a function (TRPC pages router) #235

Open
gaufranc opened this issue Sep 11, 2024 · 1 comment
Open

req.headers.get is not a function (TRPC pages router) #235

gaufranc opened this issue Sep 11, 2024 · 1 comment

Comments

@gaufranc
Copy link

gaufranc commented Sep 11, 2024

Im encountering an error when trying to implement this:
https://github.com/c-ehrlich/next-axiom-trpc-example/tree/main/pages-router

GET /api/trpc/notifications.getCountOfUserNotifications,auctions.getAuctionsHeroHome,auctions.getAuctionsEndingSoonHome,auctions.getFeaturedAuctionsHome?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%221%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%222%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%223%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D 500 in 22ms ⨯ TypeError: req.headers.get is not a function at C:\work\stringtree-nextjs\nextjs\node_modules\next-axiom\dist\withAxiom.js:75:31 at Generator.next (<anonymous>) at C:\work\stringtree-nextjs\nextjs\node_modules\next-axiom\dist\withAxiom.js:8:71 at new Promise (<anonymous>) at __awaiter (C:\work\stringtree-nextjs\nextjs\node_modules\next-axiom\dist\withAxiom.js:4:12) at C:\work\stringtree-nextjs\nextjs\node_modules\next-axiom\dist\withAxiom.js:56:26 at eval (webpack-internal:///(api)/./src/server/tools/axiomMiddleware.ts:15:92) at K (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\compiled\next-server\pages-api.runtime.dev.js:21:2877) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async U.render (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\compiled\next-server\pages-api.runtime.dev.js:21:3955) at async DevServer.runApi (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\server\next-server.js:600:9) at async NextNodeServer.handleCatchallRenderRequest (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\server\next-server.js:269:37) at async DevServer.handleRequestImpl (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\server\base-server.js:816:17) at async C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\server\dev\next-dev-server.js:339:20 at async Span.traceAsyncFn (C:\work\stringtree-nextjs\nextjs\node_modules\next\dist\trace\trace.js:154:20) { page: '/api/trpc/[trpc]' }

Thats the error im encountering, it happens on every call i make to the backend via TRPC.
The problem arises when i implement withAxiom in pages/api/trpc/[trpc].ts

I see that the package uses "req.headers.get", i tried to patch the headers im sending with no luck. Is this a common issue?

Here are my TRPC context without axiom:
`const createInnerTRPCContext = ({ auth, req }: AuthContext) => {
return {
auth,
prisma,
req,
}
}

export const createTRPCContext = (opts: CreateNextContextOptions) => {
return createInnerTRPCContext({
req: opts.req,
auth: getAuth(opts.req),
})
}`

Im trying to implement this because i linked the application with Vercel but my function logs are not showing on the Axiom dashboard

@bkdiehl
Copy link

bkdiehl commented Sep 17, 2024

I'm running into this same issue. It not only fails to log, it causes all my trpc requests to fail.

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

2 participants