Readme
Redirect from web val to val page by adding /edit
to the URL. Convention by pomdtr.
Create valimport { editRedirect } from "https://esm.town/v/stevekrouse/editRedirect";
import { Hono } from "npm:hono@3";
const app = new Hono();
app.get("/", (c) => c.text("Hello world!"));
app.get("/edit", (c) => editRedirect());
export default app.fetch;
- turn this into middleware in the style of @pomdtr/basicAuth
Live: https://stevekrouse-edit_redirect_example.web.val.run/edit
1
2
3
4
5
6
7
import { refs } from "https://esm.town/v/stevekrouse/refs";
export function editRedirect() {
const ref = refs()[0];
const editURL = `https://val.town/v/${ref.userHandle}/${ref.valName}`;
return Response.redirect(editURL);
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.