What is this?
An end-to-end system for QR codes and short links. From generation in the browser to secure redirection on a self-hosted server. Instead of relying on external services like Bitly, I built the entire chain myself: a QR code generator as a static page, a redirect microservice at go.mathis-adler.dev with a preview page and domain allowlist, and a CLI tool for link management.
The motivation: public URL shorteners track clicks, can be shut down, and are a security risk. I explain exactly why in my blog.
How It Fits Together
- QR generator: (mathis-adler.dev/qr-generator) Enter a URL, generate a QR code, download as SVG or PNG. Runs entirely in the browser — no data leaves the machine.
- Redirect service: (go.mathis-adler.dev) Node.js microservice in Docker. Every short link first shows a preview page with a countdown before the actual 302 redirect occurs. Users always see where they will be redirected.
- CLI tool: Links are created exclusively via the command line with an API key. No public interface, no potential for abuse.
Security Decisions
- Domain allowlist instead of open redirect — only redirects to predefined domains, with exact match (no endsWith that would let
evilgithub.comthrough) - 12-character Base62 tokens (~71 bits of entropy ) — too long to guess, but short enough for QR codes
- No tracking, no IP addresses, no user agent, no cookies.
- Two-tier rate limiting (Nginx + Express) — stricter for 404 responses as protection against token enumeration
- API only accessible via VPN: Nginx restricts /api/ routes to the internal network
What I Learned
- The decision not to build a public shortener radically simplified the architecture and reduced the attack surface to nearly zero
- Preview pages before redirects are minimal effort with significant security benefit