-
Notifications
You must be signed in to change notification settings - Fork 31
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
Comments
I'm running into this same issue. It not only fails to log, it causes all my trpc requests to fail. |
@bkdiehl same here. |
I'm not sure. In my case, I was upgrading from an old version of axiom (v0.17) at the same time I was upgrading my project from nextjs v12 to v14. In addition to the trpc errors I was experiencing, the public endpoints in the app also had unexpected behavior. It looks like some types/functionality were removed to support nextjs 14, but those changes appear to have removed support for using axiom with api requests. I ended up forking next-axiom v0.17 and publishing to a private npm registry with updated peer dependencies that include nextjs 14. |
Came here to report the same issue. This issue makes it impossible to use
|
Still having the same issue. `import { Logger } from 'next-axiom'
}` however this is not ideal |
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
The text was updated successfully, but these errors were encountered: