Skip to content

v0.21.0 — URL builder + signed URLs

Choose a tag to compare

@tshafer tshafer released this 10 Jul 20:52
· 147 commits to main since this release

Generate URLs from named routes, and sign them:

router.url("users.show", { id: 42 }, { qs: { tab: "posts" } });
// "/users/42?tab=posts"

const url = await router.signedUrl("download", { id: 7 }, { expiresIn: 3600 });
if (!(await router.hasValidSignature())) response.abort("Invalid link", 403);

Signed URLs use HMAC-SHA256 (Web Crypto — Node + edge), keyed by config('app.key'), and cover the path + query so any tampering invalidates the link. See docs/url-builder.md.