Loading...
Loading...
Use when building an HTTP val — a web endpoint, API route, webhook receiver, or any val that responds to HTTP requests. Covers the handler signature, Hono usage, the endpoint URL, CORS behavior, redirects, and Val Town-specific limitations.
npx skill4agent add val-town/plugins http-endpointsfileType: "http"links.endpointlist_filescreate_filefetch_val_endpointhttpPrivacyrestricted302restricted-access// Learn more: https://docs.val.town/vals/http/
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true });
}exportexport defaultapp.fetchappimport { Hono } from "npm:hono";
import { parseVal, serveImmutableFile } from "https://esm.town/v/std/utils/index.ts";
const app = new Hono();
app.get("/", (c) => c.text("hello"));
// Immutable asset caching (see the client-side-js skill): serves the
// current-version URLs your HTML shell stamps with immutableFileUrl()
app.get("/__immutable/*", (c) => serveImmutableFile(c.req.path));
// View source redirect
app.get("/source", (c) => c.redirect(parseVal().links.self.val));
// Always add this for full stack traces on errors:
app.onError((err) => Promise.reject(err));
export default app.fetch;serveStaticserveFilestaticHTTPServerstd/utilsstd/utilsreadFileserveFilestaticHTTPServerlistFileslistFilesByPathhttpEndpointparseValhttps://utilities.val.run/docs.mdAccess-Control-Allow-Origin: *corsResponse.redirectreturn new Response(null, { status: 302, headers: { Location: "/path" } });
// or, with Hono:
return c.redirect("/path");std/sqlitestd/blobget_logs<script src="https://esm.town/v/std/catch"></script>