-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
This may be not a real bug, but I had a problem. When I use @hono/mcp in my Hono app, optimize it with the hono optimize command, and deploy the optimized code. But it does not work well now. I investigated and found that the @hono/mcp uses request body APIs in the functions outside of the handler. So, if I added the option --no-request-body-api-removal, it works well.
This is a minimal code to reproduce my problem:
import { type Context, Hono } from 'hono'
const app = new Hono()
const service = async (c: Context) => {
if (c.req.method !== 'POST') {
return c.json({ message: 'Only POST requests are allowed' }, 405)
}
const receivedData = await c.req.json()
// do something with receivedData
return receivedData
}
app.all('/', async (c) => {
const result = await service(c)
return c.json({ status: 'success', result })
})
export default appThe repo: https://github.com/yusukebe/hono-cli-request-body-api-removal-bug
There will likely be some similar cases. If the user encounters this problem, it's hard to identify the cause and solution. So, making --no-request-body-api-removal as default will be a good idea, I think.
Metadata
Metadata
Assignees
Labels
No labels