Skip to content
Discussion options

You must be logged in to vote

Fixed it by serving the endpoints with OpenAPIHandler instead of RPCHandler:

// remove this import
// import { RPCHandler } from '@orpc/server/fetch' 

app.use('/rpc/*', async (c, next) => {
  const { matched, response } = await openAPIHandler.handle(c.req.raw, {
    prefix: '/rpc',
    context: {}
  })

  if (matched) {
    return c.newResponse(response.body, response)
  }

  await next()
})

After switching to OpenAPIHandler, the endpoints accept the request body directly (without the json wrapper), and the generated OpenAPI/Scalar examples work as expected.


Credit to dinwwwh on Discord for pointing me in the right direction.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hammadmajid
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by hammadmajid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants