H
Hono2mo ago
𝚔

`c.req.json()` makes my POST endpoint hang and timeout

Setup: - Vercel serverless functions, Node.js runtime - @hono/vite-build, vite-config.ts:
{
plugins: [
build({
entry: "./src/server/index.ts",
vercel: { // tried without this, still hangs
function: { shouldAddHelpers: false },
},
}),
],
resolve: { alias: { "@": path.resolve(__dirname, ".") } },
}
{
plugins: [
build({
entry: "./src/server/index.ts",
vercel: { // tried without this, still hangs
function: { shouldAddHelpers: false },
},
}),
],
resolve: { alias: { "@": path.resolve(__dirname, ".") } },
}
index.ts
import { Hono } from "hono";
import { appBridge } from "@/src/server/app-bridge";
import { connect } from "@/src/server/connect";
import { folders } from "@/src/server/folders";
import { oAuth } from "@/src/server/o-auth";
import { settings } from "@/src/server/settings";
import { translate } from "@/src/server/translate";

const app = new Hono().basePath("/api");

app.route("/app-bridge", appBridge);
app.route("/o-auth", oAuth);
app.route("/connect", connect);
app.route("/folders", folders);
app.route("/translate", translate);
app.route("/settings", settings);

export default app;
import { Hono } from "hono";
import { appBridge } from "@/src/server/app-bridge";
import { connect } from "@/src/server/connect";
import { folders } from "@/src/server/folders";
import { oAuth } from "@/src/server/o-auth";
import { settings } from "@/src/server/settings";
import { translate } from "@/src/server/translate";

const app = new Hono().basePath("/api");

app.route("/app-bridge", appBridge);
app.route("/o-auth", oAuth);
app.route("/connect", connect);
app.route("/folders", folders);
app.route("/translate", translate);
app.route("/settings", settings);

export default app;
example, /app-birdge
import { Hono } from "hono";
import { verifyAppBridgeToken } from "@/src/server/lib/app-bridge";

export const appBridge = new Hono();

appBridge.post("/", async (c) => {
const { token } = await c.req.json(); // hangs here, I tried on other endpoints, whenever I call c.req.json() it hangs. Works fine locally.:fire: :fire:
const res = await verifyAppBridgeToken(token);
return c.json(res);
});
import { Hono } from "hono";
import { verifyAppBridgeToken } from "@/src/server/lib/app-bridge";

export const appBridge = new Hono();

appBridge.post("/", async (c) => {
const { token } = await c.req.json(); // hangs here, I tried on other endpoints, whenever I call c.req.json() it hangs. Works fine locally.:fire: :fire:
const res = await verifyAppBridgeToken(token);
return c.json(res);
});
4 Replies
blair
blair2mo ago
Is it hanging or erroring on c.req.json()? I can't say I've used vercel with hono in the past but I do remember some issue with vercel's bodyparser
𝚔
𝚔OP2mo ago
Hanging
𝚔
𝚔OP2mo ago
I ended up manually parsing the body from c.env.incoming

Did you find this page helpful?