H
Hono3mo ago
veeque

How do I get rest params?

Take the following app:
import { Hono } from "hono";
import { trimTrailingSlash } from "hono/trailing-slash";

const app = new Hono();

app.use(trimTrailingSlash());

app.get("/", async (c) => {
return c.text("This is the Cloudflare page for /");
});

app.get("/app/:app/*", async (ctx) => {
return ctx.text(
`You have requested the ${ctx.req.param(
"app"
)} application on the "${ctx.req.param("*")}" path`
);
});

export default app;
import { Hono } from "hono";
import { trimTrailingSlash } from "hono/trailing-slash";

const app = new Hono();

app.use(trimTrailingSlash());

app.get("/", async (c) => {
return c.text("This is the Cloudflare page for /");
});

app.get("/app/:app/*", async (ctx) => {
return ctx.text(
`You have requested the ${ctx.req.param(
"app"
)} application on the "${ctx.req.param("*")}" path`
);
});

export default app;
It would be nice if this worked, but doing ctx.req.param("*") doesn't give you the remaining params. I need this as I have to forward those to a separate Cloudflare pages application.
1 Reply
veeque
veequeOP3mo ago
Found the solution: "/your/path/here/:rest{.+$}"
Want results from more Discord servers?
Add your server