• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

auth_middleware

Remix of pomdtr/auth_middleware
Public
Like
auth_middleware
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

Authentication middleware

Guards your public http vals behind a login page.

c2a79825e9d89429014a036c29887c670806ee3f0188e01cde09adad193a6407.png

This val use a json web token stored as an http-only cookie to persist authentication.

Usage

Set an AUTH_SECRET_KEY env variable (used to sign/verify jwt tokens). Use an API token to authenticate.

import { auth } from "https://esm.town/v/pomdtr/auth_middleware"; async function handler(req: Request): Promise<Response> { return new Response("You are authenticated!"); } export default auth(handler);

See @pomdtr/test_auth for an example

⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.

Migrated from folder: Archive/auth_middleware

Code
README.mdmain.tsx
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.