AbhishekA
Convex Community2y ago
4 replies
Abhishek

This Convex deployment does not have HTTP actions enabled.

I am trying to use Hono with Convex in my Nextjs application, but the endpoints are giving
This Convex deployment does not have HTTP actions enabled.
responses I do not know what the issue is. Can Someone please guide me to the solution or maybe a repo that has Nextjs, hono and Convex all together?

Here is the Code
import { Hono } from "hono";
import { logger } from "hono/logger";
import stripAnsi from "strip-ansi";
import { HonoWithConvex, HttpRouterWithHono } from "./lib/honoWithConvex";
import { cors } from "hono/cors";

import { internal } from "./_generated/api";

const app: HonoWithConvex = new Hono();

// Custom 404
app.notFound((c) => {
return c.text("Oh no! Couldn't find a route for that", 404);
});

// Middleware!
app.use(
"",
logger((...args) => {
console.log(...args.map(stripAnsi));
})
);

// Set up CORS as middleware
app.use("/api/
", cors());

// This endpoint should be accessible from the browser.
const apiRouter = app.basePath("/api");

// Nested as `/api/listMessages
apiRouter.get("/listMessages", async (c) => {
// Running a Convex query
const messages = await c.env.runQuery(internal.messages.listAll);

// Helpers for pretty JSON!

return c.json(messages);
});

apiRouter.get("/listMessages/:userId{[0-9]+}", async (c) => {
// Extracting a token from the URL!
const userId = c.req.param("userId");

// Running a Convex query
const messages = await c.env.runQuery(internal.messages.listByAuthor, {
authorNumber: userId,
});

// Helpers for pretty JSON!

return c.json(messages);
});

const router = new HttpRouterWithHono(app);
export default router;
Was this page helpful?