Skip to content

Is there a way to modify the request method in hono middleware? #1089

Answered by yusukebe
spencerbart asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @spencerbart

I think this is not a recommended approach, though, you can try this:

app.use('/', async (c, next) => {
  const req = c.req.raw.clone()
  c.req.raw = new Request(req, {
    method: 'POST',
  })
  await next()
  // ...
})

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by spencerbart
Comment options

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