Skip to content

Issue with Type Error in Next.js Adapter Sample Code #684

@FlatMapIO

Description

@FlatMapIO

When copying the sample code from https://orpc.unnoq.com/docs/adapters/next#next-js-adapter, I encountered a type error. The context requires a header with the type nodejs IncomingRequestHeader.

async function handleRequest(request: Request) {
  const { response } = await handler.handle(request, {
    prefix: '/rpc',
    context: {
       // type error
    }, 
  })

  return response ?? new Response('Not found', { status: 404 })
}

I have two questions for clarification:

  1. Since we're using the web standard API, could you explain why there's a Node.js-specific header requirement?
  2. The first argument of handle is already a request object—could you clarify why the header needs to be passed again in the context?

Would appreciate any guidance on resolving this or adjusting the example for better alignment with web standards. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions